summaryrefslogtreecommitdiff
path: root/same/src/main/java/com/orbekk
diff options
context:
space:
mode:
authorKjetil Ørbekk <kjetil.orbekk@gmail.com>2012-01-19 16:33:21 +0100
committerKjetil Ørbekk <kjetil.orbekk@gmail.com>2012-01-19 16:33:21 +0100
commita1c3d1ad9b2815e827e52662b91974145e9b5a20 (patch)
tree433ca43d2401bb00ca123924f0a5c173b72ad4d6 /same/src/main/java/com/orbekk
parent91b109414204db19f2aba63915045742dc87bcca (diff)
Add SameInterface – the programming interface to Same.
SameInterface is supposed to contain the library interface to Same.
Diffstat (limited to 'same/src/main/java/com/orbekk')
-rw-r--r--same/src/main/java/com/orbekk/same/SameInterface.java42
-rw-r--r--same/src/main/java/com/orbekk/same/UpdateConflict.java4
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 {
+}