TextParameterDataSegment extends AbstractDataSegment { public final boolean equals (final Object anObject) { if (anObject instanceof TextParameterDataSegment) { try { final TextParameterDataSegment anotherTPDS = (TextParameterDataSegment) anObject; return getSettings().equals(anotherTPDS.getSettings()); } catch (Exception e) { if (LOGGER.isErrorEnabled()) { LOGGER.error(e.getLocalizedMessage()); } } } return super.equals(anObject); } TextParameterDataSegment(final int initChunkSize); final void add(final OperationalTextKey textKey, final String value); final void addAll(final SettingsMap textKeys); final int append(final ByteBuffer src, final int len); final int deserialize(final ByteBuffer src, final int len); final SettingsMap getSettings(); final void clear(); final boolean equals(final Object anObject); @Override final int hashCode();  }
@Test public final void testEquals () throws Exception { final TextParameterDataSegment dataSegment = new TextParameterDataSegment(CHUNK_SIZE); assertNotNull(dataSegment); assertEquals(0, dataSegment.getLength()); dataSegment.add(OperationalTextKey.DATA_DIGEST, "Yes"); dataSegment.add(OperationalTextKey.HEADER_DIGEST, "No"); dataSegment.add(OperationalTextKey.MAX_CONNECTIONS, "50"); assertEquals(3, dataSegment.getSettings().entrySet().size()); assertFalse(dataSegment.getSettings().entrySet().isEmpty()); final TextParameterDataSegment anotherDataSegment = new TextParameterDataSegment(CHUNK_SIZE); assertNotNull(anotherDataSegment); anotherDataSegment.add(OperationalTextKey.HEADER_DIGEST, "No"); anotherDataSegment.add(OperationalTextKey.DATA_DIGEST, "Yes"); anotherDataSegment.add(OperationalTextKey.MAX_CONNECTIONS, "50"); assertEquals(3, anotherDataSegment.getSettings().entrySet().size()); assertFalse(anotherDataSegment.getSettings().entrySet().isEmpty()); assertTrue(dataSegment.equals(anotherDataSegment)); }