Class ValuePrinter

java.lang.Object
org.mockito.internal.matchers.text.ValuePrinter

public class ValuePrinter extends Object
Prints a Java object value in a way humans can read it neatly. Inspired on hamcrest. Used for printing arguments in verification errors.
  • Constructor Details

    • ValuePrinter

      private ValuePrinter()
  • Method Details

    • print

      public static String print(Object value)
      Prints given value so that it is neatly readable by humans. Handles explosive toString() implementations.
    • printMap

      private static String printMap(Map<?,?> map)
    • printValues

      public static String printValues(String start, String separator, String end, Iterator<?> values)
      Print values in a nice format, e.g. (1, 2, 3)
      Parameters:
      start - the beginning of the values, e.g. "("
      separator - the separator of values, e.g. ", "
      end - the end of the values, e.g. ")"
      values - the values to print
      Returns:
      neatly formatted value list
    • printChar

      private static String printChar(char value)
    • descriptionOf

      private static String descriptionOf(Object value)