public boolean equals(Object that) { if (this == that) return true; if (!(that instanceof StringCharacterIterator)) return false; StringCharacterIterator l = this; StringCharacterIterator r = (StringCharacterIterator) that; return l.hashCode() == r.hashCode() && Objects.equals(l.text, r.text) && !(l.pos != r.pos || l.begin != r.begin || l.end != r.end); }