/** * <p>Appends with the same format as the default <code>Object toString() * </code> method. Appends the class name followed by * {@link System#identityHashCode(java.lang.Object)}.</p> * * @param srcObject the <code>Object</code> whose class name and id to output * @return this * @since 2.0 */ public ToStringBuilder appendAsObjectToString(final Object srcObject) { ObjectUtils.identityToString(this.getStringBuffer(), srcObject); return this; }
/** * <p>Returns the built <code>toString</code>.</p> * * <p>This method appends the end of data indicator, and can only be called once. * Use {@link #getStringBuffer} to get the current string state.</p> * * <p>If the object is <code>null</code>, return the style's <code>nullText</code></p> * * @return the String <code>toString</code> */ @Override public String toString() { if (this.getObject() == null) { this.getStringBuffer().append(this.getStyle().getNullText()); } else { style.appendEnd(this.getStringBuffer(), this.getObject()); } return this.getStringBuffer().toString(); }
@Test public void testConstructToStringBuilder(){ final ToStringBuilder stringBuilder1 = new ToStringBuilder(base, null, null); final ToStringBuilder stringBuilder2 = new ToStringBuilder(base, ToStringStyle.DEFAULT_STYLE, new StringBuffer(1024)); assertEquals(ToStringStyle.DEFAULT_STYLE, stringBuilder1.getStyle()); assertNotNull(stringBuilder1.getStringBuffer()); assertNotNull(stringBuilder1.toString()); assertEquals(ToStringStyle.DEFAULT_STYLE, stringBuilder2.getStyle()); assertNotNull(stringBuilder2.getStringBuffer()); assertNotNull(stringBuilder2.toString()); }
/** * <p>Appends with the same format as the default <code>Object toString() * </code> method. Appends the class name followed by * {@link System#identityHashCode(java.lang.Object)}.</p> * * @param srcObject the <code>Object</code> whose class name and id to output * @return this * @since 2.0 */ public ToStringBuilder appendAsObjectToString(final Object srcObject) { ObjectUtils.identityToString(this.getStringBuffer(), srcObject); return this; }
/** * <p>Appends with the same format as the default <code>Object toString() * </code> method. Appends the class name followed by * {@link System#identityHashCode(java.lang.Object)}.</p> * * @param srcObject the <code>Object</code> whose class name and id to output * @return this * @since 2.0 */ public ToStringBuilder appendAsObjectToString(final Object srcObject) { ObjectUtils.identityToString(this.getStringBuffer(), srcObject); return this; }
/** * <p>Appends with the same format as the default <code>Object toString() * </code> method. Appends the class name followed by * {@link System#identityHashCode(java.lang.Object)}.</p> * * @param srcObject the <code>Object</code> whose class name and id to output * @return this * @since 2.0 */ public ToStringBuilder appendAsObjectToString(final Object srcObject) { ObjectUtils.identityToString(this.getStringBuffer(), srcObject); return this; }
/** * <p>Returns the built <code>toString</code>.</p> * * <p>This method appends the end of data indicator, and can only be called once. * Use {@link #getStringBuffer} to get the current string state.</p> * * <p>If the object is <code>null</code>, return the style's <code>nullText</code></p> * * @return the String <code>toString</code> */ @Override public String toString() { if (this.getObject() == null) { this.getStringBuffer().append(this.getStyle().getNullText()); } else { style.appendEnd(this.getStringBuffer(), this.getObject()); } return this.getStringBuffer().toString(); }
public String toString() { ToStringBuilder builder = ToString.getBuilder( this); builder.getStringBuffer() .append( getVar()) .append( '=') .append( getValue()); if( !isValueValid()) { builder.getStringBuffer() .append( ",valid=") .append( isValueValid()); } return builder.toString(); }
/** * <p>Returns the built <code>toString</code>.</p> * * <p>This method appends the end of data indicator, and can only be called once. * Use {@link #getStringBuffer} to get the current string state.</p> * * <p>If the object is <code>null</code>, return the style's <code>nullText</code></p> * * @return the String <code>toString</code> */ @Override public String toString() { if (this.getObject() == null) { this.getStringBuffer().append(this.getStyle().getNullText()); } else { style.appendEnd(this.getStringBuffer(), this.getObject()); } return this.getStringBuffer().toString(); }
/** * <p>Returns the built <code>toString</code>.</p> * * <p>This method appends the end of data indicator, and can only be called once. * Use {@link #getStringBuffer} to get the current string state.</p> * * <p>If the object is <code>null</code>, return the style's <code>nullText</code></p> * * @return the String <code>toString</code> */ @Override @GwtIncompatible("incompatible method") public String toString() { if (this.getObject() == null) { this.getStringBuffer().append(this.getStyle().getNullText()); } else { style.appendEnd(this.getStringBuffer(), this.getObject()); } return this.getStringBuffer().toString(); }