@NotThreadSafe public final class ToStringGenerator extends Object
toString method creations. It
assumes that the toString method is only used for the
representation of the internal state and not for creating human readable
formats.
A real world example for a final class derived from Object or a base
class looks like this: @Override
public String toString () {
return new ToStringGenerator (this).append ("member1", member1).append ("member2", member2).toString ();
}
For a derived class, the typical code looks like this, assuming that the base
class also used the ToStringGenerator: @Override
public String toString () {
return ToStringGenerator.getDerived (super.toString ()).append ("member3", member3).append ("member4", member4).toString ();
}
| Modifier and Type | Field and Description |
|---|---|
static String |
CONSTANT_NULL
String to be emitted for
null values |
static String |
CONSTANT_PASSWORD
String to be emited for password values
|
static String |
CONSTANT_THIS
String to be emitted for
this values |
| Constructor and Description |
|---|
ToStringGenerator(Object aSrc) |
public static final String CONSTANT_NULL
null valuespublic static final String CONSTANT_THIS
this valuespublic static final String CONSTANT_PASSWORD
@Nonnull public ToStringGenerator append(@Nonnull String sField, boolean aValue)
@Nonnull public ToStringGenerator append(@Nonnull String sField, @Nullable boolean[] aValue)
@Nonnull public ToStringGenerator append(@Nonnull String sField, byte aValue)
@Nonnull public ToStringGenerator append(@Nonnull String sField, @Nullable byte[] aValue)
@Nonnull public ToStringGenerator append(@Nonnull String sField, char aValue)
@Nonnull public ToStringGenerator append(@Nonnull String sField, @Nullable char[] aValue)
@Nonnull public ToStringGenerator append(@Nonnull String sField, double aValue)
@Nonnull public ToStringGenerator append(@Nonnull String sField, @Nullable double[] aValue)
@Nonnull public ToStringGenerator append(@Nonnull String sField, float aValue)
@Nonnull public ToStringGenerator append(@Nonnull String sField, @Nullable float[] aValue)
@Nonnull public ToStringGenerator append(@Nonnull String sField, int aValue)
@Nonnull public ToStringGenerator append(@Nonnull String sField, @Nullable int[] aValue)
@Nonnull public ToStringGenerator append(@Nonnull String sField, long aValue)
@Nonnull public ToStringGenerator append(@Nonnull String sField, @Nullable long[] aValue)
@Nonnull public ToStringGenerator append(@Nonnull String sField, short aValue)
@Nonnull public ToStringGenerator append(@Nonnull String sField, @Nullable short[] aValue)
@Nonnull public ToStringGenerator appendPassword(@Nonnull String sField)
@Nonnull public ToStringGenerator appendIfNotNull(@Nonnull String sField, @Nullable boolean[] aValue)
@Nonnull public ToStringGenerator appendIfNotNull(@Nonnull String sField, @Nullable byte[] aValue)
@Nonnull public ToStringGenerator appendIfNotNull(@Nonnull String sField, @Nullable char[] aValue)
@Nonnull public ToStringGenerator appendIfNotNull(@Nonnull String sField, @Nullable double[] aValue)
@Nonnull public ToStringGenerator appendIfNotNull(@Nonnull String sField, @Nullable float[] aValue)
@Nonnull public ToStringGenerator appendIfNotNull(@Nonnull String sField, @Nullable int[] aValue)
@Nonnull public ToStringGenerator appendIfNotNull(@Nonnull String sField, @Nullable long[] aValue)
@Nonnull public ToStringGenerator appendIfNotNull(@Nonnull String sField, @Nullable short[] aValue)
@Nonnull public ToStringGenerator appendIfNotNull(@Nonnull String sField, @Nullable Object aValue)
@Nonnull public ToStringGenerator appendIfNotNull(@Nonnull String sField, @Nullable Object[] aValue)
@Nonnull public ToStringGenerator appendIfNotEmpty(@Nonnull String sField, @Nullable boolean[] aValue)
@Nonnull public ToStringGenerator appendIfNotEmpty(@Nonnull String sField, @Nullable byte[] aValue)
@Nonnull public ToStringGenerator appendIfNotEmpty(@Nonnull String sField, @Nullable char[] aValue)
@Nonnull public ToStringGenerator appendIfNotEmpty(@Nonnull String sField, @Nullable double[] aValue)
@Nonnull public ToStringGenerator appendIfNotEmpty(@Nonnull String sField, @Nullable float[] aValue)
@Nonnull public ToStringGenerator appendIfNotEmpty(@Nonnull String sField, @Nullable int[] aValue)
@Nonnull public ToStringGenerator appendIfNotEmpty(@Nonnull String sField, @Nullable long[] aValue)
@Nonnull public ToStringGenerator appendIfNotEmpty(@Nonnull String sField, @Nullable short[] aValue)
@Nonnull public ToStringGenerator appendIfNotEmpty(@Nonnull String sField, @Nullable Object[] aValue)
@Nonnull public ToStringGenerator appendIfNotEmpty(@Nonnull String sField, @Nullable Collection<?> aValue)
@Nonnull public ToStringGenerator appendIfNotEmpty(@Nonnull String sField, @Nullable Map<?,?> aValue)
@Nonnull public static ToStringGenerator getDerived(@Nonnull String sSuperToString)
ToStringGenerator for derived classes where the base class
also uses the ToStringGenerator. This avoids that the implementing
class name is emitted more than once.sSuperToString - Always pass in super.toString ()nullCopyright © 2006–2015 phloc systems. All rights reserved.