Package org.assertj.core.presentation
Class StandardRepresentation
java.lang.Object
org.assertj.core.presentation.StandardRepresentation
- All Implemented Interfaces:
Representation
- Direct Known Subclasses:
BinaryRepresentation
,HexadecimalRepresentation
,UnicodeRepresentation
Standard java object representation.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Class<?>[]
private static final Map
<Class<?>, Function<?, ? extends CharSequence>> private static final String
private static final String
private static final String
static final String
static final String
(package private) static final String
(package private) static final String
private static int
private static int
private static int
private static final String
static final StandardRepresentation
private static final String
private static final String
private static final Class<?>[]
Fields inherited from interface org.assertj.core.presentation.Representation
DEFAULT_PRIORITY
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected String
private static Object
classNameOf
(Object obj) protected <T> String
customFormat
(T object) private String
private static boolean
doesDescriptionFitOnSingleLine
(String singleLineDescription) protected String
fallbackToStringOf
(Object object) Returns theString
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
format
(List<?> elements, String start, String end, String elementSeparator, String indentation, Object root) private String
protected String
Returns theString
representation of the given array, ornull
if the given object is eithernull
or not an array.private String
formatLines
(List<?> lines) protected String
static int
static int
static int
protected boolean
Determine whether the given object's type has a representation that is not ambiguous.protected boolean
hasCustomFormatterFor
(Object object) private static boolean
hasOverriddenToString
(Class<?> clazz) private static boolean
hasOverriddenToStringInSubclassOf
(Class<?> objectClass, Class<?> clazz) private static String
identityHexCodeOf
(Object obj) private static boolean
isInstanceOfNotOverridingToString
(Object object, Class<?> type) 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
Clear all formatters registered per type withregisterFormatterForType(Class, Function)
.representElements
(Iterable<?> elements, String start, String end, String elementSeparator, String indentation, Object root) private static String
representGroup
(List<String> representedElements, String start, String end, String elementSeparator, String indentation) static void
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 theString
representation of the givenIterable
, ornull
if the givenIterable
isnull
.protected String
smartFormat
(Object[] array) private static Map
<?, ?> toSortedMapIfPossible
(Map<?, ?> map) toString()
protected String
toStringOf
(File file) protected String
protected String
toStringOf
(Class<?> c) protected String
toStringOf
(Float f) protected String
toStringOf
(Long l) protected String
toStringOf
(Number number) toStringOf
(Object object) Returns standard thetoString
representation of the given object.protected String
toStringOf
(String s) protected String
toStringOf
(Throwable throwable) protected String
toStringOf
(SimpleDateFormat dateFormat) private String
toStringOf
(Duration duration) protected String
toStringOf
(LocalDate localDate) protected String
toStringOf
(LocalDateTime localDateTime) protected String
toStringOf
(OffsetDateTime offsetDateTime) protected String
toStringOf
(ZonedDateTime zonedDateTime) protected String
toStringOf
(Calendar calendar) protected String
toStringOf
(Comparator<?> comparator) 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
(LongAdder longAdder) protected String
toStringOf
(Future<?> future) protected String
toStringOf
(Date date) protected String
toStringOf
(Map.Entry<?, ?> javaMapEntry) protected String
toStringOf
(Map<?, ?> map) protected String
toStringOf
(MapEntry<?, ?> mapEntry) protected String
toStringOf
(Tuple tuple) protected String
toStringOf
(ComparatorBasedComparisonStrategy comparatorBasedComparisonStrategy) protected String
private String
toStringOf
(ChangeDelta<?> changeDelta) private String
toStringOf
(DeleteDelta<?> deleteDelta) private String
toStringOf
(InsertDelta<?> insertDelta) Returns theString
representation of the given object with its type and hexadecimal identity hash code so that it can be differentiated from other objects with the sametoStringOf(Object)
representation.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.assertj.core.presentation.Representation
getPriority
-
Field Details
-
NULL
- See Also:
-
STANDARD_REPRESENTATION
-
TUPLE_START
- See Also:
-
TUPLE_END
- See Also:
-
DEFAULT_START
- See Also:
-
DEFAULT_END
- See Also:
-
DEFAULT_MAX_ELEMENTS_EXCEEDED
- See Also:
-
INDENTATION_AFTER_NEWLINE
- See Also:
-
INDENTATION_FOR_SINGLE_LINE
- See Also:
-
ELEMENT_SEPARATOR
- See Also:
-
ELEMENT_SEPARATOR_WITH_NEWLINE
-
maxLengthForSingleLineDescription
private static int maxLengthForSingleLineDescription -
maxElementsForPrinting
private static int maxElementsForPrinting -
maxStackTraceElementsDisplayed
private static int maxStackTraceElementsDisplayed -
customFormatterByType
-
TYPE_WITH_UNAMBIGUOUS_REPRESENTATION
-
BLACKLISTED_ITERABLE_CLASSES
-
-
Constructor Details
-
StandardRepresentation
public StandardRepresentation()
-
-
Method Details
-
resetDefaults
public static void resetDefaults() -
setMaxLengthForSingleLineDescription
public static void setMaxLengthForSingleLineDescription(int value) -
getMaxLengthForSingleLineDescription
public static int getMaxLengthForSingleLineDescription() -
setMaxElementsForPrinting
public static void setMaxElementsForPrinting(int value) -
getMaxStackTraceElementsDisplayed
public static int getMaxStackTraceElementsDisplayed() -
setMaxStackTraceElementsDisplayed
public static void setMaxStackTraceElementsDisplayed(int value) -
getMaxElementsForPrinting
public static int getMaxElementsForPrinting() -
registerFormatterForType
Registers new formatter for the given type. All instances of the given type will be formatted with the provided formatter.- Type Parameters:
T
- the type to register a formatter for- Parameters:
type
- the class of the type to register a formatter forformatter
- the formatter
-
removeAllRegisteredFormatters
public static void removeAllRegisteredFormatters()Clear all formatters registered per type withregisterFormatterForType(Class, Function)
. -
toStringOf
Returns standard thetoString
representation of the given object. It may or not the object's own implementation oftoString
.- Specified by:
toStringOf
in interfaceRepresentation
- Parameters:
object
- the given object.- Returns:
- the
toString
representation of the given object.
-
isInstanceOfNotOverridingToString
-
hasOverriddenToString
-
hasOverriddenToStringInSubclassOf
-
unambiguousToStringOf
Returns theString
representation of the given object with its type and hexadecimal identity hash code so that it can be differentiated from other objects with the sametoStringOf(Object)
representation.- Specified by:
unambiguousToStringOf
in interfaceRepresentation
- Parameters:
obj
- the object to represent.- Returns:
- the unambiguous
toString
representation of the given object.
-
toString
-
customFormat
-
hasCustomFormatterFor
-
hasAlreadyAnUnambiguousToStringOf
Determine whether the given object's type has a representation that is not ambiguous.- Parameters:
obj
- the object to check- Returns:
- true if the given object's type has a representation that is not ambiguous, false otherwise.
-
fallbackToStringOf
Returns theString
representation of the given object. This method is used as a last resort if none of theStandardRepresentation
predefined string representations were not called.- Parameters:
object
- the object to represent (nevernull
- Returns:
- to
toString
representation for the given object
-
toStringOf
-
toStringOf
-
toStringOf
-
toStringOf
-
toStringOf
-
toStringOf
-
toStringOf
-
toStringOf
-
toStringOf
-
toStringOf
-
toStringOf
-
toStringOf
-
toStringOf
-
toStringOf
-
toStringOf
-
toStringOf
-
toStringOf
-
classNameDisambiguation
-
toStringOf
-
toStringOf
-
toStringOf
-
toStringOf
-
toStringOf
-
toStringOf
-
toStringOf
-
toStringOf
-
toStringOf
-
toStringOf
-
toStringOf
-
toStringOf
-
toStringOf
-
multiLineFormat
-
singleLineFormat
-
smartFormat
Returns theString
representation of the givenIterable
, ornull
if the givenIterable
isnull
.The
Iterable
will be formatted to a single line if it does not exceed 100 char, otherwise each element will be formatted on a new line with 4 space indentation.- Parameters:
iterable
- theIterable
to format.- Returns:
- the
String
representation of the givenIterable
.
-
formatArray
Returns theString
representation of the given array, ornull
if the given object is eithernull
or not an array. This method supports arrays having other arrays as elements.- Parameters:
o
- the object that is expected to be an array.- Returns:
- the
String
representation of the given array.
-
smartFormat
-
formatPrimitiveArray
-
multiLineFormat
-
singleLineFormat
-
format
-
format
-
format
-
safeStringOf
-
representElements
-
representGroup
-
toStringOf
-
toStringOf
-
toStringOf
-
toStringOf
-
formatLines
-
doesDescriptionFitOnSingleLine
-
identityHexCodeOf
-
classNameOf
-
defaultToStringWithClassNameDisambiguation
-
toSortedMapIfPossible
-
format
-