Text implements ParagraphElement { @Override public boolean equals(final Object o) { if (o == this) { return true; } if (!(o instanceof Text)) { return false; } final Text other = (Text) o; return this.paragraphs.equals(other.paragraphs); } Text(final List<Paragraph> paragraphs); static TextBuilder builder(); static Text content(final String text); static Text styledContent(final String text, final TextStyle ts); @Override void addEmbeddedStylesFromCell(final StylesContainer stylesContainer); @Override void addEmbeddedStylesFromFooterHeader(final StylesContainer stylesContainer); @Override void appendXMLContent(final XMLUtil util, final Appendable appendable); boolean isEmpty(); @Override boolean equals(final Object o); @Override final int hashCode(); static final String TEXT_DATE; static final String TEXT_FILE_NAME; static final String TEXT_PAGE_COUNT; static final String TEXT_PAGE_NUMBER; static final String TEXT_SHEET_NAME; static final String TEXT_TIME; }
@Test public void testEquals() { final Text text1 = Text.builder().parContent("text").link("url", "url").parStyledContent("text2", null) .span("span").build(); final Text text2 = Text.builder().par().styledSpan("text", null).link("url", "url").par().span("text2") .span("span").build(); Assert.assertEquals(text1, text1); Assert.assertNotEquals(text1, "text1"); Assert.assertNotEquals("text1", text1); Assert.assertEquals(text1, text2); Assert.assertEquals(text2, text1); }