@Test public void compareToTest() { Tag tag1 = new Tag(KEY, VALUE); Tag tag2 = new Tag(KEY, VALUE); Tag tag3 = new Tag(KEY, KEY); Tag tag4 = new Tag(VALUE, VALUE); Assert.assertTrue(tag1.compareTo(tag2) == 0); Assert.assertTrue(tag1.compareTo(tag3) < 0); Assert.assertTrue(tag1.compareTo(tag4) > 0); }
@Override public int compareTo(Tag tag) { int keyResult = this.key.compareTo(tag.key); if (keyResult != 0) { return keyResult; } return this.value.compareTo(tag.value); }
Tag implements Comparable<Tag>, Serializable { @Override public int compareTo(Tag tag) { int keyResult = this.key.compareTo(tag.key); if (keyResult != 0) { return keyResult; } return this.value.compareTo(tag.value); } }
Tag implements Comparable<Tag>, Serializable { @Override public int compareTo(Tag tag) { int keyResult = this.key.compareTo(tag.key); if (keyResult != 0) { return keyResult; } return this.value.compareTo(tag.value); } Tag(String tag);  Tag(String key, String value); private  Tag(String tag, int splitPosition); }
Tag implements Comparable<Tag>, Serializable { @Override public int compareTo(Tag tag) { int keyResult = this.key.compareTo(tag.key); if (keyResult != 0) { return keyResult; } return this.value.compareTo(tag.value); } Tag(String tag);  Tag(String key, String value); private  Tag(String tag, int splitPosition); @Override int compareTo(Tag tag); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString(); }
Tag implements Comparable<Tag>, Serializable { @Override public int compareTo(Tag tag) { int keyResult = this.key.compareTo(tag.key); if (keyResult != 0) { return keyResult; } return this.value.compareTo(tag.value); } Tag(String tag);  Tag(String key, String value); private  Tag(String tag, int splitPosition); @Override int compareTo(Tag tag); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString(); static final char KEY_VALUE_SEPARATOR; final String key; final String value; }