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 Stringprivate static final Stringprivate static final Stringstatic final Stringstatic final String(package private) static final String(package private) static final Stringprivate static intprivate static intprivate static final Stringstatic final StandardRepresentationprivate static final Stringprivate static final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected <T> StringcustomFormat(T object) private static booleandoesDescriptionFitOnSingleLine(String singleLineDescription) protected Stringprivate Stringprotected StringReturns theStringrepresentation of the given array, ornullif the given object is eithernullor not an array.protected Stringstatic intprotected booleanhasCustomFormatterFor(Object object) protected StringmultiLineFormat(Iterable<?> iterable) protected StringmultiLineFormat(Representation representation, Object[] iterable, Set<Object[]> alreadyFormatted) static <T> voidregisterFormatterForType(Class<T> type, Function<T, String> formatter) Registers new formatter for the given type.static voidClear all formatters registered per type withregisterFormatterForType(Class, Function).static voidIt resets the static defaults for the standard representation.static voidsetMaxElementsForPrinting(int value) static voidsetMaxLengthForSingleLineDescription(int value) protected StringsingleLineFormat(Iterable<?> iterable, String start, String end) protected StringsingleLineFormat(Representation representation, Object[] iterable, String start, String end, Set<Object[]> alreadyFormatted) protected StringsmartFormat(Iterable<?> iterable) Returns theStringrepresentation of the givenIterable, ornullif the givenIterableisnull.protected StringsmartFormat(Representation representation, Object[] iterable) private static Map<?,?> toSortedMapIfPossible(Map<?, ?> map) toString()protected StringtoStringOf(File f) protected Stringprotected StringtoStringOf(Class<?> c) protected StringtoStringOf(Float f) protected StringtoStringOf(Long l) protected StringtoStringOf(Number number) toStringOf(Object object) Returns standard thetoStringrepresentation of the given object.protected StringtoStringOf(String s) protected StringtoStringOf(SimpleDateFormat dateFormat) protected Stringprotected StringtoStringOf(Comparator<?> comparator) protected StringtoStringOf(AtomicBoolean atomicBoolean) protected StringtoStringOf(AtomicInteger atomicInteger) protected StringtoStringOf(AtomicLong atomicLong) protected StringtoStringOf(AtomicMarkableReference<?> atomicMarkableReference) protected StringtoStringOf(AtomicReference<?> atomicReference) protected StringtoStringOf(AtomicStampedReference<?> atomicStampedReference) protected StringtoStringOf(CompletableFuture<?> future) protected StringtoStringOf(Date d) protected StringtoStringOf(Map<?, ?> map) protected StringtoStringOf(MapEntry<?, ?> mapEntry) protected StringtoStringOf(Tuple tuple) protected StringReturns theStringrepresentation 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 = 80maxElementsForPrinting = 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 thetoStringrepresentation of the given object. It may or not the object's own implementation oftoString.- Specified by:
toStringOfin interfaceRepresentation- Parameters:
object- the given object.- Returns:
- the
toStringrepresentation of the given object.
-
customFormat
-
hasCustomFormatterFor
-
unambiguousToStringOf
Description copied from interface:RepresentationReturns theStringrepresentation 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:
unambiguousToStringOfin interfaceRepresentation- Parameters:
obj- the object to represent.- Returns:
- the
toStringrepresentation 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 theStringrepresentation of the given array, ornullif the given object is eithernullor 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
Stringrepresentation of the given array.
-
multiLineFormat
protected String multiLineFormat(Representation representation, Object[] iterable, Set<Object[]> alreadyFormatted) -
singleLineFormat
-
smartFormat
-
format
-
formatPrimitiveArray
-
format
-
multiLineFormat
-
singleLineFormat
-
smartFormat
Returns theStringrepresentation of the givenIterable, ornullif the givenIterableisnull.The
Iterablewill 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- theIterableto format.- Returns:
- the
Stringrepresentation of the givenIterable.
-
doesDescriptionFitOnSingleLine
-