GlyphLine implements Serializable { @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null || getClass() != obj.getClass()) { return false; } GlyphLine other = (GlyphLine) obj; if (end - start != other.end - other.start) { return false; } if (actualText == null && other.actualText != null || actualText != null && other.actualText == null) { return false; } for (int i = start; i < end; i++) { int otherPos = other.start + i - start; Glyph myGlyph = get(i); Glyph otherGlyph = other.get(otherPos); if (myGlyph == null && otherGlyph != null || myGlyph != null && !myGlyph.equals(otherGlyph)) { return false; } ActualText myAT = actualText == null ? null : actualText.get(i); ActualText otherAT = other.actualText == null ? null : other.actualText.get(otherPos); if (myAT == null && otherAT != null || myAT != null && !myAT.equals(otherAT)) { return false; } } return true; } GlyphLine();  GlyphLine(List<Glyph> glyphs);  GlyphLine(List<Glyph> glyphs, int start, int end); protected  GlyphLine(List<Glyph> glyphs, List<ActualText> actualText, int start, int end);  GlyphLine(GlyphLine other);  GlyphLine(GlyphLine other, int start, int end); String toUnicodeString(int start, int end); @Override String toString(); GlyphLine copy(int left, int right); Glyph get(int index); Glyph set(int index, Glyph glyph); void add(Glyph glyph); void add(int index, Glyph glyph); void setGlyphs(List<Glyph> replacementGlyphs); void add(GlyphLine other); void replaceContent(GlyphLine other); int size(); void substituteManyToOne(OpenTypeFontTableReader tableReader, int lookupFlag, int rightPartLen, int substitutionGlyphIndex); void substituteOneToOne(OpenTypeFontTableReader tableReader, int substitutionGlyphIndex); void substituteOneToMany(OpenTypeFontTableReader tableReader, int[] substGlyphIds); GlyphLine filter(IGlyphLineFilter filter); void setActualText(int left, int right, String text); Iterator<GlyphLinePart> iterator(); @Override boolean equals(Object obj); @Override int hashCode(); public int start; public int end; public int idx; }
@Test public void testEquals() { Glyph glyph = new Glyph(200, 200, 200); GlyphLine.ActualText actualText = new GlyphLine.ActualText("-"); GlyphLine one = new GlyphLine(new ArrayList<Glyph>(Arrays.asList(glyph)), new ArrayList<GlyphLine.ActualText>(Arrays.asList(actualText)), 0, 1); GlyphLine two = new GlyphLine(new ArrayList<Glyph>(Arrays.asList(glyph)), new ArrayList<GlyphLine.ActualText>(Arrays.asList(actualText)), 0, 1); one.add(glyph); two.add(glyph); one.end++; two.end++; Assert.assertTrue(one.equals(two)); }