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.
- Author:
- Mariusz Smykula, Jack Gough
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final StandardRepresentationFields inherited from interface org.assertj.core.presentation.Representation
DEFAULT_PRIORITY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected Stringprotected <T> StringcustomFormat(T object) protected StringfallbackToStringOf(Object object) Returns theStringrepresentation of the given object.protected Stringformat(Iterable<?> iterable, String start, String end, String elementSeparator, String indentation, Object root) protected Stringformat(Object[] array, String start, String end, String elementSeparator, String indentation, Object root) protected Stringformat(List<?> elements, String start, String end, String elementSeparator, String indentation, Object root) protected StringReturns theStringrepresentation of the given array, ornullif the given object is eithernullor not an array.protected Stringstatic intstatic intstatic intprotected booleanDetermine whether the given object's type has a representation that is not ambiguous.protected booleanhasCustomFormatterFor(Object object) protected StringmultiLineFormat(Iterable<?> iterable) protected StringmultiLineFormat(Object[] array, Object root) 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.protected StringsafeStringOf(Object element, String start, String end, String elementSeparator, String indentation, Object root) static voidsetMaxElementsForPrinting(int value) static voidsetMaxLengthForSingleLineDescription(int value) static voidsetMaxStackTraceElementsDisplayed(int value) protected StringsingleLineFormat(Iterable<?> iterable, String start, String end) protected StringsingleLineFormat(Object[] array, Object root) protected StringsmartFormat(Iterable<?> iterable) Returns theStringrepresentation of the givenIterable, ornullif the givenIterableisnull.protected StringsmartFormat(Object[] array) toString()protected StringtoStringOf(File file) protected Stringprotected 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(Throwable throwable) protected StringtoStringOf(SimpleDateFormat dateFormat) protected StringtoStringOf(LocalDate localDate) protected StringtoStringOf(LocalDateTime localDateTime) protected StringtoStringOf(OffsetDateTime offsetDateTime) protected StringtoStringOf(YearMonth yearMonth) protected StringtoStringOf(ZonedDateTime zonedDateTime) protected StringtoStringOf(Calendar calendar) protected 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(LongAdder longAdder) protected StringtoStringOf(Future<?> future) protected StringtoStringOf(Date date) protected StringtoStringOf(Map.Entry<?, ?> javaMapEntry) protected StringtoStringOf(Map<?, ?> map) protected StringtoStringOf(MapEntry<?, ?> mapEntry) protected StringtoStringOf(Tuple tuple) protected StringtoStringOf(ComparatorBasedComparisonStrategy comparatorBasedComparisonStrategy) protected Stringprotected StringReturns theStringrepresentation 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, waitMethods inherited from interface org.assertj.core.presentation.Representation
getPriority
-
Field Details
-
STANDARD_REPRESENTATION
-
ELEMENT_SEPARATOR
- See Also:
-
ELEMENT_SEPARATOR_WITH_NEWLINE
-
-
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 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.
-
unambiguousToStringOf
Returns theStringrepresentation 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:
unambiguousToStringOfin interfaceRepresentation- Parameters:
obj- the object to represent.- Returns:
- the unambiguous
toStringrepresentation 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 theStringrepresentation of the given object. This method is used as a last resort if none of theStandardRepresentationpredefined string representations were not called.- Parameters:
object- the object to represent (nevernull- Returns:
- to
toStringrepresentation for the given object
-
toStringOf
-
toStringOf
-
toStringOf
-
toStringOf
-
toStringOf
-
toStringOf
-
toStringOf
-
toStringOf
-
toStringOf
-
toStringOf
-
toUnquotedStringOf
-
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 theStringrepresentation of the givenIterable, ornullif the givenIterableisnull.The
Iterablewill 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- theIterableto format.- Returns:
- the
Stringrepresentation of the givenIterable.
-
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.
-
smartFormat
-
formatPrimitiveArray
-
multiLineFormat
-
singleLineFormat
-
format
-
format
-
format
-
safeStringOf
-