Language extends Resource implements LanguageId { @Override public boolean equals(Object obj) { String pk = getLanguageId(); if (pk == null || obj == null || !(obj instanceof Language)) { return false; } return pk.equals(((Language) obj).getLanguageId()); } Language(FlattrObject data); static LanguageId withId(final String id); @Override String getLanguageId(); String getName(); @Override boolean equals(Object obj); @Override int hashCode();  }
@Test public void testEquals() throws FlattrException { Language lang1 = new Language(new FlattrObject("{\"id\":\"en_GB\",\"text\":\"English\"}")); Language lang2 = new Language(new FlattrObject("{\"id\":\"en_GB\",\"text\":\"English\"}")); Language lang3 = new Language(new FlattrObject("{\"id\":\"sq_AL\",\"text\":\"Albanian\"}")); assertThat(lang1, is(equalTo(lang2))); assertThat(lang2, is(equalTo(lang1))); assertThat(lang1, not(equalTo(lang3))); assertThat(lang3, not(equalTo(lang1))); }