public class StandardRepresentation extends Object implements Representation
Modifier and Type | Field and Description |
---|---|
static String |
ELEMENT_SEPARATOR |
static String |
ELEMENT_SEPARATOR_WITH_NEWLINE |
static StandardRepresentation |
STANDARD_REPRESENTATION |
Constructor and Description |
---|
StandardRepresentation() |
Modifier and Type | Method and Description |
---|---|
protected String |
customFormat(Object object) |
String |
format(Iterable<?> iterable,
String start,
String end,
String elementSeparator,
String indentation) |
protected String |
format(Object[] array,
String elementSeparator,
String indentation,
Set<Object[]> alreadyFormatted) |
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 |
getMaxLengthForSingleLineDescription() |
protected boolean |
hasCustomFormatterFor(Object object) |
protected String |
multiLineFormat(Iterable<?> iterable) |
protected String |
multiLineFormat(Representation representation,
Object[] iterable,
Set<Object[]> alreadyFormatted) |
static void |
registerFormatterForType(Class<?> type,
Function<Object,String> formatter)
Registers new formatter for the given type.
|
static void |
removeAllRegisteredFormatters()
Clear all formatters registered per type with
registerFormatterForType(Class, Function) . |
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 the
String representation of the given Iterable , or null if the given
Iterable is null . |
protected String |
smartFormat(Representation representation,
Object[] iterable) |
String |
toString() |
protected String |
toStringOf(Calendar c) |
protected String |
toStringOf(Character c) |
protected String |
toStringOf(Class<?> c) |
protected String |
toStringOf(Comparator<?> comparator) |
protected String |
toStringOf(CompletableFuture<?> future) |
protected String |
toStringOf(Date d) |
protected String |
toStringOf(File f) |
protected String |
toStringOf(Float f) |
protected String |
toStringOf(Long l) |
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(PredicateDescription p) |
protected String |
toStringOf(SimpleDateFormat dateFormat) |
protected String |
toStringOf(String s) |
protected String |
toStringOf(Tuple tuple) |
public static final StandardRepresentation STANDARD_REPRESENTATION
public static final String ELEMENT_SEPARATOR
public static final String ELEMENT_SEPARATOR_WITH_NEWLINE
public static void setMaxLengthForSingleLineDescription(int value)
public static int getMaxLengthForSingleLineDescription()
public static void registerFormatterForType(Class<?> type, Function<Object,String> formatter)
public 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 Representation
object
- the given object.toString
representation of the given object.protected boolean hasCustomFormatterFor(Object object)
protected String toStringOf(Comparator<?> comparator)
protected String toStringOf(PredicateDescription p)
protected String toStringOf(SimpleDateFormat dateFormat)
protected String toStringOf(CompletableFuture<?> future)
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.representation
- array
- the object that is expected to be an array.String
representation of the given array.protected String multiLineFormat(Representation representation, Object[] iterable, Set<Object[]> alreadyFormatted)
protected String singleLineFormat(Representation representation, Object[] iterable, String start, String end, Set<Object[]> alreadyFormatted)
protected String smartFormat(Representation representation, Object[] iterable)
protected String format(Object[] array, String elementSeparator, String indentation, Set<Object[]> alreadyFormatted)
public String format(Iterable<?> iterable, String start, String end, String elementSeparator, String indentation)
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.
representation
- iterable
- the Iterable
to format.String
representation of the given Iterable
.Copyright © 2014–2016 AssertJ. All rights reserved.