aboutsummaryrefslogtreecommitdiff
path: root/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/config/persistence/Configuration.java
diff options
context:
space:
mode:
Diffstat (limited to 'id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/config/persistence/Configuration.java')
-rw-r--r--id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/config/persistence/Configuration.java60
1 files changed, 60 insertions, 0 deletions
diff --git a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/config/persistence/Configuration.java b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/config/persistence/Configuration.java
new file mode 100644
index 000000000..f357fc570
--- /dev/null
+++ b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/config/persistence/Configuration.java
@@ -0,0 +1,60 @@
+package at.gv.egovernment.moa.id.commons.config.persistence;
+
+import java.util.List;
+
+/**
+ * An interface for a key-value configuration.
+ */
+public interface Configuration {
+
+ /**
+ * Gets all keys in the database. NOTE: may return an empty list or {@code null}.
+ * @return a List containing all keys in the database or {@code null}.
+ */
+ List<String> getAllKeys();
+
+ /**
+ * Get the value associated with the given key as {@link Object}.
+ * @param key the key
+ * @return the object associated with the given key or {@code null} if the key does not exist or does not have a value.
+ */
+ Object get(String key);
+
+ /**
+ * Get the object of type {@code T} associated with the given key.
+ *
+ * @param key the key
+ * @param clazz the type of the requested object
+ * @return the object associated with the given key or {@code null} if the key does not exist or does not have a value.
+ */
+ <T> T get(String key, Class<T> clazz);
+
+ /**
+ * Store an object associated with a key. If the given object is set to {@code null} then the entry associated with the key is deleted.
+ *
+ * @param key the key under which the value is stored, respectively key determining the entry to be deleted.
+ * @param value the object to store. if value is set to {@code null} then the entry associated with key {@code key} is deleted.
+ * @return {@code true} if the operation was carried out successfully, {@code false} otherwise.
+ */
+ boolean set(String key, Object value);
+
+ /**
+ * Get the object of type {@code T} associated with the given key from the database. If the key does not exist or does not have a value, the given default
+ * value is returned.
+ *
+ * @param key the key
+ * @param clazz the type of the requested object
+ * @param defaultValue the default value to return
+ * @return the object associated with the given key or {@code defaultValue} if the key does not exist or does not have a value.
+ */
+ <T> T get(String key, Class<T> clazz, Object defaultValue);
+
+ /**
+ * Get a list of objects associated with the given key. The list may be empty or contain only a single object.
+ * @param key the key
+ * @param clazz the type of the requested object
+ * @return a list containing objects of type {@code T} or an empty list if no objects are associated with the key.
+ */
+ <T> List<T> getList(String key, Class<T> clazz);
+
+} \ No newline at end of file