Class ValuePrinter


  • public class ValuePrinter
    extends java.lang.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 Summary

      Constructors 
      Modifier Constructor Description
      private ValuePrinter()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      private static java.lang.String descriptionOf​(java.lang.Object value)  
      static java.lang.String print​(java.lang.Object value)
      Prints given value so that it is neatly readable by humans.
      private static java.lang.String printChar​(char value)  
      private static java.lang.String printMap​(java.util.Map<?,​?> map)  
      static java.lang.String printValues​(java.lang.String start, java.lang.String separator, java.lang.String end, java.util.Iterator<?> values)
      Print values in a nice format, e.g.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ValuePrinter

        private ValuePrinter()
    • Method Detail

      • print

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

        private static java.lang.String printMap​(java.util.Map<?,​?> map)
      • printValues

        public static java.lang.String printValues​(java.lang.String start,
                                                   java.lang.String separator,
                                                   java.lang.String end,
                                                   java.util.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 java.lang.String printChar​(char value)
      • descriptionOf

        private static java.lang.String descriptionOf​(java.lang.Object value)