EmojiRange { @Override public int hashCode() { int result = start; result = 31 * result + end; result = 31 * result + emoji.hashCode(); return result; } EmojiRange(final int start, final int end, @NonNull final Emoji emoji); @Override boolean equals(final Object o); @Override int hashCode(); final int start; final int end; final Emoji emoji; }
@Test public void hashy() { assertThat(new EmojiRange(0, 1, emoji).hashCode()).isEqualTo(new EmojiRange(0, 1, emoji).hashCode()); assertThat(new EmojiRange(0, 1, emoji2).hashCode()).isEqualTo(new EmojiRange(0, 1, emoji2).hashCode()); assertThat(new EmojiRange(0, 0, emoji2).hashCode()).isNotEqualTo(new EmojiRange(0, 1, emoji2).hashCode()); assertThat(new EmojiRange(10, 0, emoji2).hashCode()).isNotEqualTo(new EmojiRange(10, 1, emoji2).hashCode()); assertThat(new EmojiRange(0, 1, emoji).hashCode()).isNotEqualTo(new EmojiRange(0, 1, emoji2).hashCode()); }