@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 appendIf(@Nonnull String sField, boolean bValue, @Nonnull IBooleanPredicate aFilter)
@Nonnull public ToStringGenerator appendIf(@Nonnull String sField, boolean bValue, @Nonnull BooleanSupplier aFilter)
@Nonnull public ToStringGenerator appendIf(@Nonnull String sField, char cValue, @Nonnull ICharPredicate aFilter)
@Nonnull public ToStringGenerator appendIf(@Nonnull String sField, char cValue, @Nonnull BooleanSupplier aFilter)
@Nonnull public ToStringGenerator appendIf(@Nonnull String sField, int nValue, @Nonnull IntPredicate aFilter)
@Nonnull public ToStringGenerator appendIf(@Nonnull String sField, int nValue, @Nonnull BooleanSupplier aFilter)
@Nonnull public ToStringGenerator appendIf(@Nonnull String sField, long nValue, @Nonnull LongPredicate aFilter)
@Nonnull public ToStringGenerator appendIf(@Nonnull String sField, long nValue, @Nonnull BooleanSupplier aFilter)
@Nonnull public ToStringGenerator appendIf(@Nonnull String sField, double dValue, @Nonnull DoublePredicate aFilter)
@Nonnull public ToStringGenerator appendIf(@Nonnull String sField, double dValue, @Nonnull BooleanSupplier aFilter)
@Nonnull public <T> ToStringGenerator appendIf(@Nonnull String sField, @Nullable T aValue, @Nonnull Predicate<? super T> aFilter)
@Nonnull public <T> ToStringGenerator appendIf(@Nonnull String sField, @Nullable T aValue, @Nonnull BooleanSupplier aFilter)
@Nonnull public ToStringGenerator appendIfNotNull(@Nonnull String sField, @Nullable Object aValue)
@Nonnull public ToStringGenerator appendPasswordIf(@Nonnull String sField, BooleanSupplier aFilter)
@Nonnull @Deprecated public String toString()
getToString() instead@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 © 2014–2019 Philip Helger. All rights reserved.