nl.jqno.equalsverifier.util
Class Formatter

java.lang.Object
  extended by nl.jqno.equalsverifier.util.Formatter

public class Formatter
extends Object

Formats a string with the contents of one or more objects. If possible, uses each object's toString method. If this throws an exception, Formatter creates its own string representation of the object, containing its class name and the contents of its fields.

Author:
Jan Ouwens

Method Summary
 String format()
          Formats the message with the given objects.
static Formatter of(String message, Object... objects)
          Factory method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

of

public static Formatter of(String message,
                           Object... objects)
Factory method.

Parameters:
message - The string that will be formatted. The substring %% represents the location where each object's will string representation will be inserted.
objects - The objects whose string representation will be inserted into the message string.
Returns:
A Formatter.

format

public String format()
Formats the message with the given objects.

Returns:
The message, with the given objects's string representations inserted into it.
Throws:
IllegalStateException - if the number of %%'s in the message does not match the number of objects.


Copyright © 2015. All Rights Reserved.