Category extends Resource implements CategoryId { @Override public boolean equals(Object obj) { String pk = getCategoryId(); if (pk == null || obj == null || !(obj instanceof Category)) { return false; } return pk.equals(((Category) obj).getCategoryId()); } Category(FlattrObject data); static CategoryId withId(final String id); @Override String getCategoryId(); String getName(); @Override boolean equals(Object obj); @Override int hashCode();  }
@Test public void testEquals() throws FlattrException { Category cat1 = new Category(new FlattrObject("{\"id\":\"images\",\"text\":\"Images\"}")); Category cat2 = new Category(new FlattrObject("{\"id\":\"images\",\"text\":\"Images\"}")); Category cat3 = new Category(new FlattrObject("{\"id\":\"audio\",\"text\":\"Audio\"}")); assertThat(cat1, is(equalTo(cat2))); assertThat(cat2, is(equalTo(cat1))); assertThat(cat1, not(equalTo(cat3))); assertThat(cat3, not(equalTo(cat1))); }