Class StandardRepresentation

    • 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
      • maxElementsForPrinting

        private static int maxElementsForPrinting
      • customFormatterByType

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

        private static final java.lang.Class<?>[] TYPE_WITH_UNAMBIGUOUS_REPRESENTATION
    • 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)
      • getMaxElementsForPrinting

        public static int getMaxElementsForPrinting()
      • 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.
        Type Parameters:
        T - the type to register a formatter for
        Parameters:
        type - the class of the type to register a formatter for
        formatter - the 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 identity hash code so that it can be differentiated from other objects with the same Representation.toStringOf(Object) representation.
        Specified by:
        unambiguousToStringOf in interface Representation
        Parameters:
        obj - the object to represent.
        Returns:
        the unambiguous toString representation of the given object.
      • hasAlreadyAnUnambiguousToStringOf

        protected boolean hasAlreadyAnUnambiguousToStringOf​(java.lang.Object obj)
        Determine whether the given object's type has a representation that is not ambiguous.
        Parameters:
        obj - the object to check
        Returns:
        true if the given object's type has a representation that is not ambiguous, false otherwise.
      • fallbackToStringOf

        protected java.lang.String fallbackToStringOf​(java.lang.Object object)
        Returns the String representation of the given object. This method is used as a last resort if none of the StandardRepresentation predefined string representations were not called.
        Parameters:
        object - the object to represent (never null
        Returns:
        to toString representation for 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.concurrent.atomic.LongAdder longAdder)
      • toStringOf

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

        protected java.lang.String toStringOf​(java.util.Calendar calendar)
      • 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 date)
      • toStringOf

        protected java.lang.String toStringOf​(java.time.LocalDateTime localDateTime)
      • toStringOf

        protected java.lang.String toStringOf​(java.time.OffsetDateTime offsetDateTime)
      • toStringOf

        protected java.lang.String toStringOf​(java.time.ZonedDateTime zonedDateTime)
      • toStringOf

        protected java.lang.String toStringOf​(java.time.LocalDate localDate)
      • classNameDisambiguation

        protected java.lang.String classNameDisambiguation​(java.lang.Object o)
      • defaultToStringWithClassNameDisambiguation

        private java.lang.String defaultToStringWithClassNameDisambiguation​(java.lang.Object o)
      • 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 file)
      • 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)
      • toStringOf

        private java.lang.String toStringOf​(ChangeDelta<?> changeDelta)
      • toStringOf

        private java.lang.String toStringOf​(DeleteDelta<?> deleteDelta)
      • toStringOf

        private java.lang.String toStringOf​(InsertDelta<?> insertDelta)
      • toStringOf

        private java.lang.String toStringOf​(java.time.Duration duration)
      • formatLines

        private java.lang.String formatLines​(java.util.List<?> lines)
      • 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​(java.lang.Object[] iterable,
                                                   java.util.Set<java.lang.Object[]> alreadyFormatted)
      • singleLineFormat

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

        protected java.lang.String smartFormat​(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)
      • identityHexCodeOf

        private static java.lang.String identityHexCodeOf​(java.lang.Object obj)
      • classNameOf

        private static java.lang.Object classNameOf​(java.lang.Object obj)