diff options
-rw-r--r-- | same/src/main/java/com/orbekk/same/SameInterface.java | 42 | ||||
-rw-r--r-- | same/src/main/java/com/orbekk/same/UpdateConflict.java | 4 |
2 files changed, 46 insertions, 0 deletions
diff --git a/same/src/main/java/com/orbekk/same/SameInterface.java b/same/src/main/java/com/orbekk/same/SameInterface.java new file mode 100644 index 0000000..a778f39 --- /dev/null +++ b/same/src/main/java/com/orbekk/same/SameInterface.java @@ -0,0 +1,42 @@ +package com.orbekk.same; + +import java.util.List; + +import org.codehaus.jackson.type.TypeReference; + +public interface SameInterface { + /** + * Get the state with identifier 'id'. + */ + String get(String id); + + /** + * Get the state with identifier 'id', converted to a Java + * object of type T using Jackson. + */ + <T> T get(String id, TypeReference<T> type); + + /** + * Get the state with identifier 'id' as a list. + */ + List<String> getList(String id); + + /** + * Set the state. + * + * @throws UpdateConflictException + */ + void set(String id, String data) throws UpdateConflict; + + /** + * Set the state. + * + * Retry until there is no conflict. + */ + void forceSet(String id, String data); + + /** + * Set from an object: Pass it, e.g., a List<String>. + */ + void setObject(String id, Object data); +} diff --git a/same/src/main/java/com/orbekk/same/UpdateConflict.java b/same/src/main/java/com/orbekk/same/UpdateConflict.java new file mode 100644 index 0000000..35fbb01 --- /dev/null +++ b/same/src/main/java/com/orbekk/same/UpdateConflict.java @@ -0,0 +1,4 @@ +package com.orbekk.same; + +public class UpdateConflict extends Exception { +} |