Top Description Fields Constructors Methods
org.assertj.core.error

public Class MessageFormatter

extends Object
Class Inheritance
Static Imports
java.util.Objects.requireNonNull, org.assertj.core.util.Strings.formatIfArgs

Formats the messages to be included in assertion errors.
Author
Alex Ruiz

Field Summary

Modifier and TypeField and Description
pack-priv DescriptionFormatter
private static final MessageFormatter

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
private String
public String

Returns:

A formatted String.
format
(Description
the description of the failed assertion, may be null.
d
,
Representation
the Representation used
p
,
String
the format string.
format
,
Object...
arguments referenced by the format specifiers in the format string.
args
)

Interprets a printf-style format String for failed assertion messages.

private Object[]
public static MessageFormatter
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

descriptionFormatterback to summary
pack-priv DescriptionFormatter descriptionFormatter
Annotations
@VisibleForTesting
INSTANCEback to summary
private static final MessageFormatter INSTANCE

Constructor Detail

MessageFormatterback to summary
pack-priv MessageFormatter()
Annotations
@VisibleForTesting

Method Detail

asTextback to summary
private String asText(Representation p, Object o)
formatback to summary
public String format(Description d, Representation p, String format, Object... args)

Interprets a printf-style format String for failed assertion messages. It is similar to String#format(String, Object...), except for:

  1. the value of the given Description is used as the first argument referenced in the format string
  2. each of the arguments in the given array is converted to a String by invoking org.assertj.core.presentation.Representation#toStringOf(Object).
Parameters
d:Description

the description of the failed assertion, may be null.

p:Representation

the Representation used

format:String

the format string.

args:Object[]

arguments referenced by the format specifiers in the format string.

Returns:String

A formatted String.

Exceptions
NullPointerException:
if the format string is null.
formatback to summary
private Object[] format(Representation p, Object[] args)
instanceback to summary
public static MessageFormatter instance()