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.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate 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 final String
static final StandardRepresentation
private static final String
private static final String
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected <T> String
customFormat
(T object) private static boolean
doesDescriptionFitOnSingleLine
(String singleLineDescription) protected String
private String
protected String
Returns theString
representation of the given array, ornull
if the given object is eithernull
or not an array.protected String
static int
protected boolean
hasCustomFormatterFor
(Object object) protected String
multiLineFormat
(Iterable<?> iterable) protected String
multiLineFormat
(Representation representation, Object[] iterable, Set<Object[]> alreadyFormatted) 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)
.static void
It resets the static defaults for the standard representation.static void
setMaxElementsForPrinting
(int value) static void
setMaxLengthForSingleLineDescription
(int value) protected String
singleLineFormat
(Iterable<?> iterable, String start, String end) protected String
singleLineFormat
(Representation representation, Object[] iterable, String start, String end, Set<Object[]> alreadyFormatted) protected String
smartFormat
(Iterable<?> iterable) Returns theString
representation of the givenIterable
, ornull
if the givenIterable
isnull
.protected String
smartFormat
(Representation representation, Object[] iterable) private static Map
<?, ?> toSortedMapIfPossible
(Map<?, ?> map) toString()
protected String
toStringOf
(File f) 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
(SimpleDateFormat dateFormat) protected String
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
(CompletableFuture<?> future) protected String
toStringOf
(Date d) protected String
toStringOf
(Map<?, ?> map) protected String
toStringOf
(MapEntry<?, ?> mapEntry) protected String
toStringOf
(Tuple tuple) protected String
Returns theString
representation of the given object with its type and hexadecimal hash code so that it can be differentied from other objects with the sameRepresentation.toStringOf(Object)
representation.
-
Field Details
-
STANDARD_REPRESENTATION
-
NULL
- See Also:
-
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 -
customFormatterByType
-
maxElementsForPrinting
private static int maxElementsForPrinting
-
-
Constructor Details
-
StandardRepresentation
public StandardRepresentation()
-
-
Method Details
-
resetDefaults
public static void resetDefaults()It resets the static defaults for the standard representation.The following defaults will be reapplied:
maxLengthForSingleLineDescription = 80
maxElementsForPrinting = 1000
-
setMaxLengthForSingleLineDescription
public static void setMaxLengthForSingleLineDescription(int value) -
getMaxLengthForSingleLineDescription
public static int getMaxLengthForSingleLineDescription() -
setMaxElementsForPrinting
public static void setMaxElementsForPrinting(int value) -
registerFormatterForType
Registers new formatter for the given type. All instances of the given type will be formatted with the provided 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.
-
customFormat
-
hasCustomFormatterFor
-
unambiguousToStringOf
Description copied from interface:Representation
Returns theString
representation of the given object with its type and hexadecimal hash code so that it can be differentied from other objects with the sameRepresentation.toStringOf(Object)
representation.- Specified by:
unambiguousToStringOf
in interfaceRepresentation
- Parameters:
obj
- the object to represent.- Returns:
- the
toString
representation of the given object.
-
toStringOf
-
toStringOf
-
toStringOf
-
toStringOf
-
toStringOf
-
toStringOf
-
toStringOf
-
toStringOf
-
toStringOf
-
toStringOf
-
toStringOf
-
toStringOf
-
toStringOf
-
toStringOf
-
toStringOf
-
toStringOf
-
toStringOf
-
toStringOf
-
toStringOf
-
toSortedMapIfPossible
-
format
-
toStringOf
-
toStringOf
-
toStringOf
-
toString
-
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.
-
multiLineFormat
protected String multiLineFormat(Representation representation, Object[] iterable, Set<Object[]> alreadyFormatted) -
singleLineFormat
-
smartFormat
-
format
-
formatPrimitiveArray
-
format
-
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 elements will be formatted on a new line with 4 space indentation.- Parameters:
iterable
- theIterable
to format.- Returns:
- the
String
representation of the givenIterable
.
-
doesDescriptionFitOnSingleLine
-