@Test public void testEquals() throws Exception { LanguageSample sampleA = new LanguageSample(new Language("aLang"), "aContext"); LanguageSample sampleA1 = new LanguageSample(new Language("aLang"), "aContext"); LanguageSample sampleB = new LanguageSample(new Language("bLang"), "aContext"); LanguageSample sampleC = new LanguageSample(new Language("aLang"), "bContext"); Assert.assertEquals(sampleA, sampleA); Assert.assertEquals(sampleA, sampleA1); Assert.assertNotEquals(sampleA, sampleB); Assert.assertNotEquals(sampleA, sampleC); Assert.assertNotEquals(sampleB, sampleC); Assert.assertNotEquals(sampleA, "something else"); }
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj instanceof LanguageSample) { LanguageSample a = (LanguageSample) obj; return getLanguage().equals(a.getLanguage()) && getContext().equals(a.getContext()); } return false; }
LanguageSample implements Serializable { @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj instanceof LanguageSample) { LanguageSample a = (LanguageSample) obj; return getLanguage().equals(a.getLanguage()) && getContext().equals(a.getContext()); } return false; } }
LanguageSample implements Serializable { @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj instanceof LanguageSample) { LanguageSample a = (LanguageSample) obj; return getLanguage().equals(a.getLanguage()) && getContext().equals(a.getContext()); } return false; } LanguageSample(Language language, CharSequence context); }
LanguageSample implements Serializable { @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj instanceof LanguageSample) { LanguageSample a = (LanguageSample) obj; return getLanguage().equals(a.getLanguage()) && getContext().equals(a.getContext()); } return false; } LanguageSample(Language language, CharSequence context); Language getLanguage(); CharSequence getContext(); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); }
LanguageSample implements Serializable { @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj instanceof LanguageSample) { LanguageSample a = (LanguageSample) obj; return getLanguage().equals(a.getLanguage()) && getContext().equals(a.getContext()); } return false; } LanguageSample(Language language, CharSequence context); Language getLanguage(); CharSequence getContext(); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj);  }