@Test public void testEquals() throws Exception { WriteOperation op1 = new WriteOperation(new Element(OUR_KEY, "someValue")); WriteOperation op2 = new WriteOperation(new Element(OUR_KEY, "someOtherValue")); WriteOperation op3 = new WriteOperation(new Element(OUR_KEY, "someValue")); WriteOperation op4 = new WriteOperation(new Element("otherKey", "someValue")); assertThat("Two write operations for the same key and same value should be equal", op1.equals(op3), is(true)); assertThat("Two write operations for the same key, but with different values should be different", op1.equals(op2), is(false)); assertThat("Two write operations for the different keys should be different", op1.equals(op4), is(false)); }
@Override public boolean equals(final Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; final WriteOperation that = (WriteOperation) o; return element.getKey().equals(that.element.getKey()) && element.getValue().equals(that.element.getValue()); }
WriteOperation implements SingleOperation { @Override public boolean equals(final Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; final WriteOperation that = (WriteOperation) o; return element.getKey().equals(that.element.getKey()) && element.getValue().equals(that.element.getValue()); } }
WriteOperation implements SingleOperation { @Override public boolean equals(final Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; final WriteOperation that = (WriteOperation) o; return element.getKey().equals(that.element.getKey()) && element.getValue().equals(that.element.getValue()); } WriteOperation(Element element);  WriteOperation(Element element, long creationTime); }
WriteOperation implements SingleOperation { @Override public boolean equals(final Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; final WriteOperation that = (WriteOperation) o; return element.getKey().equals(that.element.getKey()) && element.getValue().equals(that.element.getValue()); } WriteOperation(Element element);  WriteOperation(Element element, long creationTime); void performSingleOperation(CacheWriter cacheWriter); BatchOperation createBatchOperation(List<SingleOperation> operations); Object getKey(); long getCreationTime(); Element getElement(); SingleOperationType getType(); @Override boolean equals(final Object o); @Override int hashCode(); }
WriteOperation implements SingleOperation { @Override public boolean equals(final Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; final WriteOperation that = (WriteOperation) o; return element.getKey().equals(that.element.getKey()) && element.getValue().equals(that.element.getValue()); } WriteOperation(Element element);  WriteOperation(Element element, long creationTime); void performSingleOperation(CacheWriter cacheWriter); BatchOperation createBatchOperation(List<SingleOperation> operations); Object getKey(); long getCreationTime(); Element getElement(); SingleOperationType getType(); @Override boolean equals(final Object o); @Override int hashCode();  }