diff options
author | Kjetil Ørbekk <kjetil.orbekk@gmail.com> | 2012-01-16 20:02:33 +0100 |
---|---|---|
committer | Kjetil Ørbekk <kjetil.orbekk@gmail.com> | 2012-01-16 20:02:33 +0100 |
commit | 080bad3ea5707021c1ae3c33abc0b0e3aca6b908 (patch) | |
tree | a5e7f98127937424684da0be68d37bfa03a80dcd /same/src/main/java | |
parent | 03883f9e08f7319138b3ec26aff333711f2699f7 (diff) |
Fix failing test.
Add equals() to State.
Diffstat (limited to 'same/src/main/java')
-rw-r--r-- | same/src/main/java/com/orbekk/same/State.java | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/same/src/main/java/com/orbekk/same/State.java b/same/src/main/java/com/orbekk/same/State.java index 3371958..4179dcb 100644 --- a/same/src/main/java/com/orbekk/same/State.java +++ b/same/src/main/java/com/orbekk/same/State.java @@ -19,7 +19,7 @@ import org.slf4j.LoggerFactory; /** * This class is thread-safe. */ -public class State implements Comparable<State> { +public class State { private Logger logger = LoggerFactory.getLogger(getClass()); private Map<String, Component> state = new HashMap<String, Component>(); private ObjectMapper mapper = new ObjectMapper(); @@ -199,12 +199,34 @@ public class State implements Comparable<State> { } @Override public String toString() { - return this.data + " @" + revision; + return "[" + this.name + ": " + this.data + "@" + revision + "]"; + } + + @Override public boolean equals(Object other) { + if (!(other instanceof Component)) { + return false; + } + Component o = (Component)other; + return name == o.name && data == o.data && revision == o.revision; } } - @Override - public int compareTo(State other) { - return -1; + + @Override public String toString() { + StringBuilder output = new StringBuilder(); + output.append("State(\n"); + for (Component c : getComponents()) { + output.append(" " + c.toString() + "\n"); + } + output.append(")"); + return output.toString(); + } + + @Override public boolean equals(Object other) { + if (!(other instanceof State)) { + return false; + } + State o = (State)other; + return state.equals(o.state); } // |