summaryrefslogtreecommitdiff
path: root/same/src/main
diff options
context:
space:
mode:
authorKjetil Ørbekk <kjetil.orbekk@gmail.com>2012-02-27 16:04:10 +0100
committerKjetil Ørbekk <kjetil.orbekk@gmail.com>2012-02-27 16:04:10 +0100
commitee51a98e9b61336610d667de57a8cff70d0ac1d9 (patch)
tree2a9e84c0d7830c68fb229bbf9cb13ae95cbb691b /same/src/main
parent500f94ce6780e96e503d6e5d9d46b5d537813717 (diff)
Remove set(id, value, revision) from ClientInterface.
Fix equals() bug in Component. Fix failing test.
Diffstat (limited to 'same/src/main')
-rw-r--r--same/src/main/java/com/orbekk/same/Client.java1
-rw-r--r--same/src/main/java/com/orbekk/same/ClientInterface.java1
-rw-r--r--same/src/main/java/com/orbekk/same/State.java3
-rw-r--r--same/src/main/java/com/orbekk/same/VariableFactory.java4
4 files changed, 5 insertions, 4 deletions
diff --git a/same/src/main/java/com/orbekk/same/Client.java b/same/src/main/java/com/orbekk/same/Client.java
index b496aac..d29147b 100644
--- a/same/src/main/java/com/orbekk/same/Client.java
+++ b/same/src/main/java/com/orbekk/same/Client.java
@@ -32,7 +32,6 @@ public class Client implements DiscoveryListener {
return new State(state);
}
- @Override
public void set(String name, String data, long revision)
throws UpdateConflict {
String masterUrl = state.getDataOf(".masterUrl");
diff --git a/same/src/main/java/com/orbekk/same/ClientInterface.java b/same/src/main/java/com/orbekk/same/ClientInterface.java
index 4b4c731..c534fce 100644
--- a/same/src/main/java/com/orbekk/same/ClientInterface.java
+++ b/same/src/main/java/com/orbekk/same/ClientInterface.java
@@ -2,7 +2,6 @@ package com.orbekk.same;
public interface ClientInterface {
State getState();
- void set(String name, String data, long revision) throws UpdateConflict;
void set(State.Component component) throws UpdateConflict;
void addStateListener(StateChangedListener listener);
void removeStateListener(StateChangedListener listener);
diff --git a/same/src/main/java/com/orbekk/same/State.java b/same/src/main/java/com/orbekk/same/State.java
index 627f79e..2b48a00 100644
--- a/same/src/main/java/com/orbekk/same/State.java
+++ b/same/src/main/java/com/orbekk/same/State.java
@@ -234,7 +234,8 @@ public class State {
return false;
}
Component o = (Component)other;
- return name == o.name && data == o.data && revision == o.revision;
+ return name.equals(o.name) && data.equals(o.data) &&
+ revision == o.revision;
}
}
diff --git a/same/src/main/java/com/orbekk/same/VariableFactory.java b/same/src/main/java/com/orbekk/same/VariableFactory.java
index 8c786c0..3f3b19c 100644
--- a/same/src/main/java/com/orbekk/same/VariableFactory.java
+++ b/same/src/main/java/com/orbekk/same/VariableFactory.java
@@ -40,7 +40,9 @@ public class VariableFactory {
public void set(T value) throws UpdateConflict {
try {
String serializedValue = mapper.writeValueAsString(value);
- client.set(identifier, serializedValue, revision);
+ State.Component update = new State.Component(identifier,
+ revision, serializedValue);
+ client.set(update);
} catch (JsonGenerationException e) {
logger.warn("Failed to convert to JSON: {}", value);
logger.warn("Parse exception.", e);