/** * Compares this text against the specified object for equality. Returns <code>true</code> if the * specified object is a text having the same character sequence as this text. For generic * comparison with any character sequence the {@link #contentEquals(CharSequence)} should be used. * * @param obj the object to compare with or <code>null</code>. * @return <code>true</code> if that is a text with the same character sequence as this text; * <code>false</code> otherwise. */ public boolean equals(Object obj) { if (this == obj) return true; if (!(obj instanceof ImmutableText)) return false; final ImmutableText that = (ImmutableText) obj; if (this._count != that._count) return false; for (int i = 0; i < _count; ) { if (this.charAt(i) != that.charAt(i++)) return false; } return true; }