@Override public boolean equals(Object o) { if (o instanceof CompoundMap) { CompoundMap other = (CompoundMap) o; Iterator<Tag<?>> iThis = iterator(); Iterator<Tag<?>> iOther = other.iterator(); while (iThis.hasNext() && iOther.hasNext()) { Tag tThis = iThis.next(); Tag tOther = iOther.next(); if (!tThis.equals(tOther)) { return false; } } if (iThis.hasNext() || iOther.hasNext()) { return false; } return true; } else { return false; } } }
@Override public boolean equals(Object o) { if (o instanceof CompoundMap) { CompoundMap other = (CompoundMap) o; Iterator<Tag<?>> iThis = iterator(); Iterator<Tag<?>> iOther = other.iterator(); while (iThis.hasNext() && iOther.hasNext()) { Tag tThis = iThis.next(); Tag tOther = iOther.next(); if (!tThis.equals(tOther)) { return false; } } if (iThis.hasNext() || iOther.hasNext()) { return false; } return true; } else { return false; } } }
@Override public boolean equals(Object o) { if (o instanceof CompoundMap) { CompoundMap other = (CompoundMap) o; Iterator<Tag<?>> iThis = iterator(); Iterator<Tag<?>> iOther = other.iterator(); while (iThis.hasNext() && iOther.hasNext()) { Tag tThis = iThis.next(); Tag tOther = iOther.next(); if (!tThis.equals(tOther)) { return false; } } if (iThis.hasNext() || iOther.hasNext()) { return false; } return true; } else { return false; } } }
@Override public int compareTo(Tag other) { if (equals(other)) { return 0; } else { if (other.getName().equals(getName())) { throw new IllegalStateException("Cannot compare two Tags with the same name but different values for sorting"); } else { return getName().compareTo(other.getName()); } } }
@Override public int compareTo(Tag other) { if (equals(other)) { return 0; } else { if (other.getName().equals(getName())) { throw new IllegalStateException("Cannot compare two Tags with the same name but different values for sorting"); } else { return getName().compareTo(other.getName()); } } }
@Override public int compareTo(Tag other) { if (equals(other)) { return 0; } else { if (other.getName().equals(getName())) { throw new IllegalStateException("Cannot compare two Tags with the same name but different values for sorting"); } else { return getName().compareTo(other.getName()); } } }
private void assertEquals(String message, Iterable<Tag<?>> a, Iterable<Tag<?>> b) { Iterator<Tag<?>> iterA = a.iterator(); Iterator<Tag<?>> iterB = b.iterator(); while (iterA.hasNext() && iterB.hasNext()) { Tag currentA = iterA.next(); Tag currentB = iterB.next(); assertTrue(message, currentA.equals(currentB)); } assertFalse("Maps had different lengths", iterA.hasNext() || iterB.hasNext()); } }