@Test public void testHashCode() { Utf8 first = new Utf8("abcd"); Utf8 second = new Utf8("abdd"); Assert.assertEquals("hashCode(Utf8) == hashCode(Utf8)", CharSequences.hashCode(first), CharSequences.hashCode(new Utf8(first))); Assert.assertEquals("hashCode(Utf8) == hashCode(String)", CharSequences.hashCode(first), CharSequences.hashCode(first.toString())); Assert.assertEquals("hashCode(String) == hashCode(String)", CharSequences.hashCode(first.toString()), CharSequences.hashCode(first.toString())); Assert.assertEquals("hashCode(Utf8) == hashCode(Utf8)", CharSequences.hashCode(second), CharSequences.hashCode(new Utf8(second))); Assert.assertEquals("hashCode(Utf8) == hashCode(String)", CharSequences.hashCode(second), CharSequences.hashCode(second.toString())); Assert.assertEquals("hashCode(String) == hashCode(String)", CharSequences.hashCode(second.toString()), CharSequences.hashCode(second.toString())); Assert.assertFalse("(a != b) => hashCode(a) != hashCode(b) (mostly)", CharSequences.hashCode(first) == CharSequences.hashCode(second)); }
public static int hashCode(CharSequence seq) { final int prime = 37; int result = 13; for (int i = 0, n = seq.length(); i < n; i += 1) { result = prime * result + seq.charAt(i); } return result; }
CharSequences { public static int hashCode(CharSequence seq) { final int prime = 37; int result = 13; for (int i = 0, n = seq.length(); i < n; i += 1) { result = prime * result + seq.charAt(i); } return result; } }
CharSequences { public static int hashCode(CharSequence seq) { final int prime = 37; int result = 13; for (int i = 0, n = seq.length(); i < n; i += 1) { result = prime * result + seq.charAt(i); } return result; }  }
CharSequences { public static int hashCode(CharSequence seq) { final int prime = 37; int result = 13; for (int i = 0, n = seq.length(); i < n; i += 1) { result = prime * result + seq.charAt(i); } return result; }  static int compare(CharSequence left, CharSequence right); static int hashCode(CharSequence seq); }
CharSequences { public static int hashCode(CharSequence seq) { final int prime = 37; int result = 13; for (int i = 0, n = seq.length(); i < n; i += 1) { result = prime * result + seq.charAt(i); } return result; }  static int compare(CharSequence left, CharSequence right); static int hashCode(CharSequence seq);  }