@Test public void testEquals() { String key = "some key"; long size = 15; StoredObjectMetadata metadata1 = new StoredObjectMetadata(key, size); StoredObjectMetadata metadata2 = new StoredObjectMetadata("some other key", size); StoredObjectMetadata metadata3 = new StoredObjectMetadata(key, 16); new EqualsTester() .addEqualityGroup(new Object()) .addEqualityGroup( metadata1, metadata1, new StoredObjectMetadata(metadata1.getKey(), metadata1.getSize())) .addEqualityGroup(metadata2) .addEqualityGroup(metadata3) .addEqualityGroup(metadata1.toString()) .addEqualityGroup(metadata2.toString()) .addEqualityGroup(metadata3.toString()) .testEquals(); }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (!(o instanceof StoredObjectMetadata)) { return false; } StoredObjectMetadata other = (StoredObjectMetadata) o; return _key.equals(other._key) && _size == other._size; }
StoredObjectMetadata { @Override public boolean equals(Object o) { if (this == o) { return true; } if (!(o instanceof StoredObjectMetadata)) { return false; } StoredObjectMetadata other = (StoredObjectMetadata) o; return _key.equals(other._key) && _size == other._size; } }
StoredObjectMetadata { @Override public boolean equals(Object o) { if (this == o) { return true; } if (!(o instanceof StoredObjectMetadata)) { return false; } StoredObjectMetadata other = (StoredObjectMetadata) o; return _key.equals(other._key) && _size == other._size; } StoredObjectMetadata(String key, long size); }
StoredObjectMetadata { @Override public boolean equals(Object o) { if (this == o) { return true; } if (!(o instanceof StoredObjectMetadata)) { return false; } StoredObjectMetadata other = (StoredObjectMetadata) o; return _key.equals(other._key) && _size == other._size; } StoredObjectMetadata(String key, long size); @JsonProperty(PROP_KEY) @Nonnull String getKey(); @JsonProperty(PROP_SIZE) long getSize(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }
StoredObjectMetadata { @Override public boolean equals(Object o) { if (this == o) { return true; } if (!(o instanceof StoredObjectMetadata)) { return false; } StoredObjectMetadata other = (StoredObjectMetadata) o; return _key.equals(other._key) && _size == other._size; } StoredObjectMetadata(String key, long size); @JsonProperty(PROP_KEY) @Nonnull String getKey(); @JsonProperty(PROP_SIZE) long getSize(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString();  }