Class StandardRepresentation

    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected <T> java.lang.String customFormat​(T object)  
      private static boolean doesDescriptionFitOnSingleLine​(java.lang.String singleLineDescription)  
      java.lang.String format​(java.lang.Iterable<?> iterable, java.lang.String start, java.lang.String end, java.lang.String elementSeparator, java.lang.String indentation)  
      protected java.lang.String format​(java.lang.Object[] array, java.lang.String elementSeparator, java.lang.String indentation, java.util.Set<java.lang.Object[]> alreadyFormatted)  
      private java.lang.String format​(java.util.Map<?,​?> map, java.lang.Object o)  
      protected java.lang.String formatArray​(java.lang.Object o)
      Returns the String representation of the given array, or null if the given object is either null or not an array.
      protected java.lang.String formatPrimitiveArray​(java.lang.Object o)  
      static int getMaxLengthForSingleLineDescription()  
      protected boolean hasCustomFormatterFor​(java.lang.Object object)  
      protected java.lang.String multiLineFormat​(java.lang.Iterable<?> iterable)  
      protected java.lang.String multiLineFormat​(Representation representation, java.lang.Object[] iterable, java.util.Set<java.lang.Object[]> alreadyFormatted)  
      static <T> void registerFormatterForType​(java.lang.Class<T> type, java.util.function.Function<T,​java.lang.String> formatter)
      Registers new formatter for the given type.
      static void removeAllRegisteredFormatters()
      Clear all formatters registered per type with registerFormatterForType(Class, Function).
      static void resetDefaults()
      It resets the static defaults for the standard representation.
      static void setMaxElementsForPrinting​(int value)  
      static void setMaxLengthForSingleLineDescription​(int value)  
      protected java.lang.String singleLineFormat​(java.lang.Iterable<?> iterable, java.lang.String start, java.lang.String end)  
      protected java.lang.String singleLineFormat​(Representation representation, java.lang.Object[] iterable, java.lang.String start, java.lang.String end, java.util.Set<java.lang.Object[]> alreadyFormatted)  
      protected java.lang.String smartFormat​(java.lang.Iterable<?> iterable)
      Returns the String representation of the given Iterable, or null if the given Iterable is null.
      protected java.lang.String smartFormat​(Representation representation, java.lang.Object[] iterable)  
      private static java.util.Map<?,​?> toSortedMapIfPossible​(java.util.Map<?,​?> map)  
      java.lang.String toString()  
      protected java.lang.String toStringOf​(java.io.File f)  
      protected java.lang.String toStringOf​(java.lang.Character c)  
      protected java.lang.String toStringOf​(java.lang.Class<?> c)  
      protected java.lang.String toStringOf​(java.lang.Float f)  
      protected java.lang.String toStringOf​(java.lang.Long l)  
      protected java.lang.String toStringOf​(java.lang.Number number)  
      java.lang.String toStringOf​(java.lang.Object object)
      Returns standard the toString representation of the given object.
      protected java.lang.String toStringOf​(java.lang.String s)  
      protected java.lang.String toStringOf​(java.text.SimpleDateFormat dateFormat)  
      protected java.lang.String toStringOf​(java.util.Calendar c)  
      protected java.lang.String toStringOf​(java.util.Comparator<?> comparator)  
      protected java.lang.String toStringOf​(java.util.concurrent.atomic.AtomicBoolean atomicBoolean)  
      protected java.lang.String toStringOf​(java.util.concurrent.atomic.AtomicInteger atomicInteger)  
      protected java.lang.String toStringOf​(java.util.concurrent.atomic.AtomicLong atomicLong)  
      protected java.lang.String toStringOf​(java.util.concurrent.atomic.AtomicMarkableReference<?> atomicMarkableReference)  
      protected java.lang.String toStringOf​(java.util.concurrent.atomic.AtomicReference<?> atomicReference)  
      protected java.lang.String toStringOf​(java.util.concurrent.atomic.AtomicStampedReference<?> atomicStampedReference)  
      protected java.lang.String toStringOf​(java.util.concurrent.CompletableFuture<?> future)  
      protected java.lang.String toStringOf​(java.util.Date d)  
      protected java.lang.String toStringOf​(java.util.Map<?,​?> map)  
      protected java.lang.String toStringOf​(MapEntry<?,​?> mapEntry)  
      protected java.lang.String toStringOf​(Tuple tuple)  
      protected java.lang.String toStringOf​(PredicateDescription p)  
      java.lang.String unambiguousToStringOf​(java.lang.Object obj)
      Returns the String representation of the given object with its type and hexadecimal hash code so that it can be differentied from other objects with the same Representation.toStringOf(Object) representation.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • DEFAULT_MAX_ELEMENTS_EXCEEDED

        private static final java.lang.String DEFAULT_MAX_ELEMENTS_EXCEEDED
        See Also:
        Constant Field Values
      • INDENTATION_AFTER_NEWLINE

        static final java.lang.String INDENTATION_AFTER_NEWLINE
        See Also:
        Constant Field Values
      • INDENTATION_FOR_SINGLE_LINE

        static final java.lang.String INDENTATION_FOR_SINGLE_LINE
        See Also:
        Constant Field Values
      • ELEMENT_SEPARATOR

        public static final java.lang.String ELEMENT_SEPARATOR
        See Also:
        Constant Field Values
      • ELEMENT_SEPARATOR_WITH_NEWLINE

        public static final java.lang.String ELEMENT_SEPARATOR_WITH_NEWLINE
      • maxLengthForSingleLineDescription

        private static int maxLengthForSingleLineDescription
      • customFormatterByType

        private static final java.util.Map<java.lang.Class<?>,​java.util.function.Function<?,​java.lang.String>> customFormatterByType
      • maxElementsForPrinting

        private static int maxElementsForPrinting
    • Constructor Detail

      • StandardRepresentation

        public StandardRepresentation()
    • Method Detail

      • resetDefaults

        public static void resetDefaults()
        It resets the static defaults for the standard representation.

        The following defaults will be reapplied:

        • maxLengthForSingleLineDescription = 80
        • maxElementsForPrinting = 1000
      • setMaxLengthForSingleLineDescription

        public static void setMaxLengthForSingleLineDescription​(int value)
      • getMaxLengthForSingleLineDescription

        public static int getMaxLengthForSingleLineDescription()
      • setMaxElementsForPrinting

        public static void setMaxElementsForPrinting​(int value)
      • registerFormatterForType

        public static <T> void registerFormatterForType​(java.lang.Class<T> type,
                                                        java.util.function.Function<T,​java.lang.String> formatter)
        Registers new formatter for the given type. All instances of the given type will be formatted with the provided formatter.
      • toStringOf

        public java.lang.String toStringOf​(java.lang.Object object)
        Returns standard the toString representation of the given object. It may or not the object's own implementation of toString.
        Specified by:
        toStringOf in interface Representation
        Parameters:
        object - the given object.
        Returns:
        the toString representation of the given object.
      • customFormat

        protected <T> java.lang.String customFormat​(T object)
      • hasCustomFormatterFor

        protected boolean hasCustomFormatterFor​(java.lang.Object object)
      • unambiguousToStringOf

        public java.lang.String unambiguousToStringOf​(java.lang.Object obj)
        Description copied from interface: Representation
        Returns the String representation of the given object with its type and hexadecimal hash code so that it can be differentied from other objects with the same Representation.toStringOf(Object) representation.
        Specified by:
        unambiguousToStringOf in interface Representation
        Parameters:
        obj - the object to represent.
        Returns:
        the toString representation of the given object.
      • toStringOf

        protected java.lang.String toStringOf​(java.lang.Number number)
      • toStringOf

        protected java.lang.String toStringOf​(java.util.concurrent.atomic.AtomicBoolean atomicBoolean)
      • toStringOf

        protected java.lang.String toStringOf​(java.util.concurrent.atomic.AtomicInteger atomicInteger)
      • toStringOf

        protected java.lang.String toStringOf​(java.util.concurrent.atomic.AtomicLong atomicLong)
      • toStringOf

        protected java.lang.String toStringOf​(java.util.Comparator<?> comparator)
      • toStringOf

        protected java.lang.String toStringOf​(java.util.Calendar c)
      • toStringOf

        protected java.lang.String toStringOf​(java.lang.Class<?> c)
      • toStringOf

        protected java.lang.String toStringOf​(java.lang.String s)
      • toStringOf

        protected java.lang.String toStringOf​(java.lang.Character c)
      • toStringOf

        protected java.lang.String toStringOf​(java.util.Date d)
      • toStringOf

        protected java.lang.String toStringOf​(java.lang.Float f)
      • toStringOf

        protected java.lang.String toStringOf​(java.lang.Long l)
      • toStringOf

        protected java.lang.String toStringOf​(java.io.File f)
      • toStringOf

        protected java.lang.String toStringOf​(java.text.SimpleDateFormat dateFormat)
      • toStringOf

        protected java.lang.String toStringOf​(java.util.concurrent.CompletableFuture<?> future)
      • toStringOf

        protected java.lang.String toStringOf​(Tuple tuple)
      • toStringOf

        protected java.lang.String toStringOf​(MapEntry<?,​?> mapEntry)
      • toStringOf

        protected java.lang.String toStringOf​(java.util.Map<?,​?> map)
      • toSortedMapIfPossible

        private static java.util.Map<?,​?> toSortedMapIfPossible​(java.util.Map<?,​?> map)
      • format

        private java.lang.String format​(java.util.Map<?,​?> map,
                                        java.lang.Object o)
      • toStringOf

        protected java.lang.String toStringOf​(java.util.concurrent.atomic.AtomicReference<?> atomicReference)
      • toStringOf

        protected java.lang.String toStringOf​(java.util.concurrent.atomic.AtomicMarkableReference<?> atomicMarkableReference)
      • toStringOf

        protected java.lang.String toStringOf​(java.util.concurrent.atomic.AtomicStampedReference<?> atomicStampedReference)
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • formatArray

        protected java.lang.String formatArray​(java.lang.Object o)
        Returns the 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.
        Parameters:
        o - the object that is expected to be an array.
        Returns:
        the String representation of the given array.
      • multiLineFormat

        protected java.lang.String multiLineFormat​(Representation representation,
                                                   java.lang.Object[] iterable,
                                                   java.util.Set<java.lang.Object[]> alreadyFormatted)
      • singleLineFormat

        protected java.lang.String singleLineFormat​(Representation representation,
                                                    java.lang.Object[] iterable,
                                                    java.lang.String start,
                                                    java.lang.String end,
                                                    java.util.Set<java.lang.Object[]> alreadyFormatted)
      • smartFormat

        protected java.lang.String smartFormat​(Representation representation,
                                               java.lang.Object[] iterable)
      • format

        protected java.lang.String format​(java.lang.Object[] array,
                                          java.lang.String elementSeparator,
                                          java.lang.String indentation,
                                          java.util.Set<java.lang.Object[]> alreadyFormatted)
      • formatPrimitiveArray

        protected java.lang.String formatPrimitiveArray​(java.lang.Object o)
      • format

        public java.lang.String format​(java.lang.Iterable<?> iterable,
                                       java.lang.String start,
                                       java.lang.String end,
                                       java.lang.String elementSeparator,
                                       java.lang.String indentation)
      • multiLineFormat

        protected java.lang.String multiLineFormat​(java.lang.Iterable<?> iterable)
      • singleLineFormat

        protected java.lang.String singleLineFormat​(java.lang.Iterable<?> iterable,
                                                    java.lang.String start,
                                                    java.lang.String end)
      • smartFormat

        protected java.lang.String smartFormat​(java.lang.Iterable<?> iterable)
        Returns the 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.

        Parameters:
        iterable - the Iterable to format.
        Returns:
        the String representation of the given Iterable.
      • doesDescriptionFitOnSingleLine

        private static boolean doesDescriptionFitOnSingleLine​(java.lang.String singleLineDescription)