From a1c3d1ad9b2815e827e52662b91974145e9b5a20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kjetil=20=C3=98rbekk?= Date: Thu, 19 Jan 2012 16:33:21 +0100 Subject: =?UTF-8?q?Add=20SameInterface=20=E2=80=93=20the=20programming=20i?= =?UTF-8?q?nterface=20to=20Same.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit SameInterface is supposed to contain the library interface to Same. --- .../main/java/com/orbekk/same/SameInterface.java | 42 ++++++++++++++++++++++ .../main/java/com/orbekk/same/UpdateConflict.java | 4 +++ 2 files changed, 46 insertions(+) create mode 100644 same/src/main/java/com/orbekk/same/SameInterface.java create mode 100644 same/src/main/java/com/orbekk/same/UpdateConflict.java 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 get(String id, TypeReference type); + + /** + * Get the state with identifier 'id' as a list. + */ + List 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. + */ + 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 { +} -- cgit v1.2.3