EmojiInformation { @Override public int hashCode() { int result = isOnlyEmojis ? 1 : 0; result = 31 * result + emojis.hashCode(); return result; } EmojiInformation(final boolean isOnlyEmojis, @NonNull final List<EmojiRange> emojis); @Override boolean equals(final Object o); @Override int hashCode(); final boolean isOnlyEmojis; @NonNull final List<EmojiRange> emojis; }
@Test public void hashy() { assertThat(empty.hashCode()).isEqualTo(empty2.hashCode()); assertThat(one.hashCode()).isEqualTo(one2.hashCode()); assertThat(one.hashCode()).isNotEqualTo(empty.hashCode()); assertThat(empty.hashCode()).isNotEqualTo(one.hashCode()); }