public class StandardRepresentation extends Object implements Representation
| Modifier and Type | Class and Description |
|---|---|
protected static class |
StandardRepresentation.GroupType |
| Modifier and Type | Field and Description |
|---|---|
static String |
ELEMENT_SEPARATOR |
static String |
ELEMENT_SEPARATOR_WITH_NEWLINE |
static StandardRepresentation |
STANDARD_REPRESENTATION |
DEFAULT_PRIORITY| Constructor and Description |
|---|
StandardRepresentation() |
| Modifier and Type | Method and Description |
|---|---|
protected String |
classNameDisambiguation(Object o) |
protected <T> String |
customFormat(T object) |
protected String |
fallbackToStringOf(Object object)
Returns the
String representation of the given object. |
protected String |
format(Iterable<?> iterable,
String start,
String end,
String elementSeparator,
String indentation,
Object root) |
protected String |
format(Object[] array,
String start,
String end,
String elementSeparator,
String indentation,
Object root) |
protected String |
formatArray(Object o)
Returns the
String representation of the given array, or null if the given object is either
null or not an array. |
protected String |
formatPrimitiveArray(Object o) |
static int |
getMaxElementsForPrinting() |
static int |
getMaxLengthForSingleLineDescription() |
static int |
getMaxStackTraceElementsDisplayed() |
protected boolean |
hasAlreadyAnUnambiguousToStringOf(Object obj)
Determine whether the given object's type has a representation that is not ambiguous.
|
protected boolean |
hasCustomFormatterFor(Object object) |
protected String |
multiLineFormat(Iterable<?> iterable) |
protected String |
multiLineFormat(Object[] array,
Object root) |
static <T> void |
registerFormatterForType(Class<T> type,
Function<T,String> formatter)
Registers new formatter for the given type.
|
static void |
removeAllRegisteredFormatters()
Clear all formatters registered per type with
registerFormatterForType(Class, Function). |
static void |
resetDefaults()
It resets the static defaults for the standard representation.
|
protected String |
safeStringOf(Object element,
String start,
String end,
String elementSeparator,
String indentation,
Object root) |
static void |
setMaxElementsForPrinting(int value) |
static void |
setMaxLengthForSingleLineDescription(int value) |
static void |
setMaxStackTraceElementsDisplayed(int value) |
protected String |
singleLineFormat(Iterable<?> iterable,
String start,
String end) |
protected String |
singleLineFormat(Object[] array,
Object root) |
protected String |
smartFormat(Iterable<?> iterable)
Returns the
String representation of the given Iterable, or null if the given
Iterable is null. |
protected String |
smartFormat(Object[] array) |
String |
toString() |
protected String |
toStringOf(AtomicBoolean atomicBoolean) |
protected String |
toStringOf(AtomicInteger atomicInteger) |
protected String |
toStringOf(AtomicLong atomicLong) |
protected String |
toStringOf(AtomicMarkableReference<?> atomicMarkableReference) |
protected String |
toStringOf(AtomicReference<?> atomicReference) |
protected String |
toStringOf(AtomicStampedReference<?> atomicStampedReference) |
protected String |
toStringOf(Calendar calendar) |
protected String |
toStringOf(Character c) |
protected String |
toStringOf(Class<?> c) |
protected String |
toStringOf(Comparator<?> comparator) |
protected String |
toStringOf(ComparatorBasedComparisonStrategy comparatorBasedComparisonStrategy) |
protected String |
toStringOf(Date date) |
protected String |
toStringOf(File file) |
protected String |
toStringOf(Float f) |
protected String |
toStringOf(Future<?> future) |
protected String |
toStringOf(LocalDate localDate) |
protected String |
toStringOf(LocalDateTime localDateTime) |
protected String |
toStringOf(Long l) |
protected String |
toStringOf(LongAdder longAdder) |
protected String |
toStringOf(Map.Entry<?,?> javaMapEntry) |
protected String |
toStringOf(Map<?,?> map) |
protected String |
toStringOf(MapEntry<?,?> mapEntry) |
protected String |
toStringOf(Number number) |
String |
toStringOf(Object object)
Returns standard the
toString representation of the given object. |
protected String |
toStringOf(OffsetDateTime offsetDateTime) |
protected String |
toStringOf(PredicateDescription p) |
protected String |
toStringOf(SimpleDateFormat dateFormat) |
protected String |
toStringOf(String s) |
protected String |
toStringOf(Throwable throwable) |
protected String |
toStringOf(Tuple tuple) |
protected String |
toStringOf(ZonedDateTime zonedDateTime) |
String |
unambiguousToStringOf(Object obj)
Returns the
String representation of the given object with its type and hexadecimal identity hash code so that
it can be differentiated from other objects with the same toStringOf(Object) representation. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetPrioritypublic static final StandardRepresentation STANDARD_REPRESENTATION
public static final String ELEMENT_SEPARATOR
public static final String ELEMENT_SEPARATOR_WITH_NEWLINE
public static void resetDefaults()
public static void setMaxLengthForSingleLineDescription(int value)
public static int getMaxLengthForSingleLineDescription()
public static void setMaxElementsForPrinting(int value)
public static int getMaxStackTraceElementsDisplayed()
public static void setMaxStackTraceElementsDisplayed(int value)
public static int getMaxElementsForPrinting()
public static <T> void registerFormatterForType(Class<T> type, Function<T,String> formatter)
T - the type to register a formatter fortype - the class of the type to register a formatter forformatter - the formatterpublic static void removeAllRegisteredFormatters()
registerFormatterForType(Class, Function).public String toStringOf(Object object)
toString representation of the given object. It may or not the object's own
implementation of toString.toStringOf in interface Representationobject - the given object.toString representation of the given object.public String unambiguousToStringOf(Object obj)
String representation of the given object with its type and hexadecimal identity hash code so that
it can be differentiated from other objects with the same toStringOf(Object) representation.unambiguousToStringOf in interface Representationobj - the object to represent.toString representation of the given object.protected <T> String customFormat(T object)
protected boolean hasCustomFormatterFor(Object object)
protected boolean hasAlreadyAnUnambiguousToStringOf(Object obj)
obj - the object to checkprotected String fallbackToStringOf(Object object)
String representation of the given object. This method is used as a last resort if none of
the StandardRepresentation predefined string representations were not called.object - the object to represent (never nulltoString representation for the given objectprotected String toStringOf(AtomicBoolean atomicBoolean)
protected String toStringOf(AtomicInteger atomicInteger)
protected String toStringOf(AtomicLong atomicLong)
protected String toStringOf(Comparator<?> comparator)
protected String toStringOf(ComparatorBasedComparisonStrategy comparatorBasedComparisonStrategy)
protected String toStringOf(PredicateDescription p)
protected String toStringOf(LocalDateTime localDateTime)
protected String toStringOf(OffsetDateTime offsetDateTime)
protected String toStringOf(ZonedDateTime zonedDateTime)
protected String toStringOf(SimpleDateFormat dateFormat)
protected String toStringOf(AtomicReference<?> atomicReference)
protected String toStringOf(AtomicMarkableReference<?> atomicMarkableReference)
protected String toStringOf(AtomicStampedReference<?> atomicStampedReference)
protected String smartFormat(Iterable<?> iterable)
String representation of the given Iterable, or null if the given
Iterable is null.
The Iterable will be formatted to a single line if it does not exceed 100 char, otherwise each elements
will be formatted on a new line with 4 space indentation.
iterable - the Iterable to format.String representation of the given Iterable.protected String formatArray(Object o)
String representation of the given array, or null if the given object is either
null or not an array. This method supports arrays having other arrays as elements.o - the object that is expected to be an array.String representation of the given array.protected String format(Object[] array, String start, String end, String elementSeparator, String indentation, Object root)
protected String format(Iterable<?> iterable, String start, String end, String elementSeparator, String indentation, Object root)
Copyright © 2025. All rights reserved.