Class GridToStringBuilder

  • Direct Known Subclasses:
    S

    public class GridToStringBuilder
    extends Object
    Provides auto-generation framework for toString() output.

    In case of recursion, repeatable objects will be shown as "ClassName@hash". But fields will be printed only for the first entry to prevent recursion.

    Default exclusion policy (can be overridden with GridToStringInclude annotation):

    • Constructor Detail

      • GridToStringBuilder

        public GridToStringBuilder()
    • Method Detail

      • includeSensitive

        public static boolean includeSensitive()
        Return true if need to include sensitive data otherwise false.
        Returns:
        true if need to include sensitive data otherwise false.
        See Also:
        setIncludeSensitiveSupplier(Supplier)
      • identity

        public static String identity​(Object obj)
        Parameters:
        obj - Object.
        Returns:
        Hexed identity hashcode.
      • toString

        public static <T> String toString​(Class<T> cls,
                                          T obj,
                                          String name0,
                                          Object val0,
                                          String name1,
                                          Object val1,
                                          String name2,
                                          Object val2,
                                          String name3,
                                          Object val3,
                                          String name4,
                                          Object val4)
        Produces auto-generated output of string presentation for given object and its declaration class.
        Type Parameters:
        T - Type of the object.
        Parameters:
        cls - Declaration class of the object. Note that this should not be a runtime class.
        obj - Object to get a string presentation for.
        name0 - Additional parameter name.
        val0 - Additional parameter value.
        name1 - Additional parameter name.
        val1 - Additional parameter value.
        name2 - Additional parameter name.
        val2 - Additional parameter value.
        name3 - Additional parameter name.
        val3 - Additional parameter value.
        name4 - Additional parameter name.
        val4 - Additional parameter value.
        Returns:
        String presentation of the given object.
      • toString

        public static <T> String toString​(Class<T> cls,
                                          T obj,
                                          String name0,
                                          Object val0,
                                          String name1,
                                          Object val1,
                                          String name2,
                                          Object val2,
                                          String name3,
                                          Object val3,
                                          String name4,
                                          Object val4,
                                          String name5,
                                          Object val5)
        Produces auto-generated output of string presentation for given object and its declaration class.
        Type Parameters:
        T - Type of the object.
        Parameters:
        cls - Declaration class of the object. Note that this should not be a runtime class.
        obj - Object to get a string presentation for.
        name0 - Additional parameter name.
        val0 - Additional parameter value.
        name1 - Additional parameter name.
        val1 - Additional parameter value.
        name2 - Additional parameter name.
        val2 - Additional parameter value.
        name3 - Additional parameter name.
        val3 - Additional parameter value.
        name4 - Additional parameter name.
        val4 - Additional parameter value.
        name5 - Additional parameter name.
        val5 - Additional parameter value.
        Returns:
        String presentation of the given object.
      • toString

        public static <T> String toString​(Class<T> cls,
                                          T obj,
                                          String name0,
                                          Object val0,
                                          String name1,
                                          Object val1,
                                          String name2,
                                          Object val2,
                                          String name3,
                                          Object val3,
                                          String name4,
                                          Object val4,
                                          String name5,
                                          Object val5,
                                          String name6,
                                          Object val6)
        Produces auto-generated output of string presentation for given object and its declaration class.
        Type Parameters:
        T - Type of the object.
        Parameters:
        cls - Declaration class of the object. Note that this should not be a runtime class.
        obj - Object to get a string presentation for.
        name0 - Additional parameter name.
        val0 - Additional parameter value.
        name1 - Additional parameter name.
        val1 - Additional parameter value.
        name2 - Additional parameter name.
        val2 - Additional parameter value.
        name3 - Additional parameter name.
        val3 - Additional parameter value.
        name4 - Additional parameter name.
        val4 - Additional parameter value.
        name5 - Additional parameter name.
        val5 - Additional parameter value.
        name6 - Additional parameter name.
        val6 - Additional parameter value.
        Returns:
        String presentation of the given object.
      • toString

        public static <T> String toString​(Class<T> cls,
                                          T obj,
                                          String name0,
                                          Object val0,
                                          boolean sens0,
                                          String name1,
                                          Object val1,
                                          boolean sens1,
                                          String name2,
                                          Object val2,
                                          boolean sens2,
                                          String name3,
                                          Object val3,
                                          boolean sens3,
                                          String name4,
                                          Object val4,
                                          boolean sens4)
        Produces auto-generated output of string presentation for given object and its declaration class.
        Type Parameters:
        T - Type of the object.
        Parameters:
        cls - Declaration class of the object. Note that this should not be a runtime class.
        obj - Object to get a string presentation for.
        name0 - Additional parameter name.
        val0 - Additional parameter value.
        sens0 - Property sensitive flag.
        name1 - Additional parameter name.
        val1 - Additional parameter value.
        sens1 - Property sensitive flag.
        name2 - Additional parameter name.
        val2 - Additional parameter value.
        sens2 - Property sensitive flag.
        name3 - Additional parameter name.
        val3 - Additional parameter value.
        sens3 - Property sensitive flag.
        name4 - Additional parameter name.
        val4 - Additional parameter value.
        sens4 - Property sensitive flag.
        Returns:
        String presentation of the given object.
      • toString

        public static <T> String toString​(Class<T> cls,
                                          T obj,
                                          String name0,
                                          Object val0,
                                          boolean sens0,
                                          String name1,
                                          Object val1,
                                          boolean sens1,
                                          String name2,
                                          Object val2,
                                          boolean sens2,
                                          String name3,
                                          Object val3,
                                          boolean sens3,
                                          String name4,
                                          Object val4,
                                          boolean sens4,
                                          String name5,
                                          Object val5,
                                          boolean sens5)
        Produces auto-generated output of string presentation for given object and its declaration class.
        Type Parameters:
        T - Type of the object.
        Parameters:
        cls - Declaration class of the object. Note that this should not be a runtime class.
        obj - Object to get a string presentation for.
        name0 - Additional parameter name.
        val0 - Additional parameter value.
        sens0 - Property sensitive flag.
        name1 - Additional parameter name.
        val1 - Additional parameter value.
        sens1 - Property sensitive flag.
        name2 - Additional parameter name.
        val2 - Additional parameter value.
        sens2 - Property sensitive flag.
        name3 - Additional parameter name.
        val3 - Additional parameter value.
        sens3 - Property sensitive flag.
        name4 - Additional parameter name.
        val4 - Additional parameter value.
        sens4 - Property sensitive flag.
        name5 - Additional parameter name.
        val5 - Additional parameter value.
        sens5 - Property sensitive flag.
        Returns:
        String presentation of the given object.
      • toString

        public static <T> String toString​(Class<T> cls,
                                          T obj,
                                          String name0,
                                          Object val0,
                                          boolean sens0,
                                          String name1,
                                          Object val1,
                                          boolean sens1,
                                          String name2,
                                          Object val2,
                                          boolean sens2,
                                          String name3,
                                          Object val3,
                                          boolean sens3,
                                          String name4,
                                          Object val4,
                                          boolean sens4,
                                          String name5,
                                          Object val5,
                                          boolean sens5,
                                          String name6,
                                          Object val6,
                                          boolean sens6)
        Produces auto-generated output of string presentation for given object and its declaration class.
        Type Parameters:
        T - Type of the object.
        Parameters:
        cls - Declaration class of the object. Note that this should not be a runtime class.
        obj - Object to get a string presentation for.
        name0 - Additional parameter name.
        val0 - Additional parameter value.
        sens0 - Property sensitive flag.
        name1 - Additional parameter name.
        val1 - Additional parameter value.
        sens1 - Property sensitive flag.
        name2 - Additional parameter name.
        val2 - Additional parameter value.
        sens2 - Property sensitive flag.
        name3 - Additional parameter name.
        val3 - Additional parameter value.
        sens3 - Property sensitive flag.
        name4 - Additional parameter name.
        val4 - Additional parameter value.
        sens4 - Property sensitive flag.
        name5 - Additional parameter name.
        val5 - Additional parameter value.
        sens5 - Property sensitive flag.
        name6 - Additional parameter name.
        val6 - Additional parameter value.
        sens6 - Property sensitive flag.
        Returns:
        String presentation of the given object.
      • toString

        public static <T> String toString​(Class<T> cls,
                                          T obj,
                                          String name0,
                                          Object val0,
                                          String name1,
                                          Object val1,
                                          String name2,
                                          Object val2,
                                          String name3,
                                          Object val3)
        Produces auto-generated output of string presentation for given object and its declaration class.
        Type Parameters:
        T - Type of the object.
        Parameters:
        cls - Declaration class of the object. Note that this should not be a runtime class.
        obj - Object to get a string presentation for.
        name0 - Additional parameter name.
        val0 - Additional parameter value.
        name1 - Additional parameter name.
        val1 - Additional parameter value.
        name2 - Additional parameter name.
        val2 - Additional parameter value.
        name3 - Additional parameter name.
        val3 - Additional parameter value.
        Returns:
        String presentation of the given object.
      • toString

        public static <T> String toString​(Class<T> cls,
                                          T obj,
                                          String name0,
                                          Object val0,
                                          boolean sens0,
                                          String name1,
                                          Object val1,
                                          boolean sens1,
                                          String name2,
                                          Object val2,
                                          boolean sens2,
                                          String name3,
                                          Object val3,
                                          boolean sens3)
        Produces auto-generated output of string presentation for given object and its declaration class.
        Type Parameters:
        T - Type of the object.
        Parameters:
        cls - Declaration class of the object. Note that this should not be a runtime class.
        obj - Object to get a string presentation for.
        name0 - Additional parameter name.
        val0 - Additional parameter value.
        sens0 - Property sensitive flag.
        name1 - Additional parameter name.
        val1 - Additional parameter value.
        sens1 - Property sensitive flag.
        name2 - Additional parameter name.
        val2 - Additional parameter value.
        sens2 - Property sensitive flag.
        name3 - Additional parameter name.
        val3 - Additional parameter value.
        sens3 - Property sensitive flag.
        Returns:
        String presentation of the given object.
      • toString

        public static <T> String toString​(Class<T> cls,
                                          T obj,
                                          String name0,
                                          Object val0,
                                          String name1,
                                          Object val1,
                                          String name2,
                                          Object val2)
        Produces auto-generated output of string presentation for given object and its declaration class.
        Type Parameters:
        T - Type of the object.
        Parameters:
        cls - Declaration class of the object. Note that this should not be a runtime class.
        obj - Object to get a string presentation for.
        name0 - Additional parameter name.
        val0 - Additional parameter value.
        name1 - Additional parameter name.
        val1 - Additional parameter value.
        name2 - Additional parameter name.
        val2 - Additional parameter value.
        Returns:
        String presentation of the given object.
      • toString

        public static <T> String toString​(Class<T> cls,
                                          T obj,
                                          String name0,
                                          Object val0,
                                          boolean sens0,
                                          String name1,
                                          Object val1,
                                          boolean sens1,
                                          String name2,
                                          Object val2,
                                          boolean sens2)
        Produces auto-generated output of string presentation for given object and its declaration class.
        Type Parameters:
        T - Type of the object.
        Parameters:
        cls - Declaration class of the object. Note that this should not be a runtime class.
        obj - Object to get a string presentation for.
        name0 - Additional parameter name.
        val0 - Additional parameter value.
        sens0 - Property sensitive flag.
        name1 - Additional parameter name.
        val1 - Additional parameter value.
        sens1 - Property sensitive flag.
        name2 - Additional parameter name.
        val2 - Additional parameter value.
        sens2 - Property sensitive flag.
        Returns:
        String presentation of the given object.
      • toString

        public static <T> String toString​(Class<T> cls,
                                          T obj,
                                          String name0,
                                          Object val0,
                                          String name1,
                                          Object val1)
        Produces auto-generated output of string presentation for given object and its declaration class.
        Type Parameters:
        T - Type of the object.
        Parameters:
        cls - Declaration class of the object. Note that this should not be a runtime class.
        obj - Object to get a string presentation for.
        name0 - Additional parameter name.
        val0 - Additional parameter value.
        name1 - Additional parameter name.
        val1 - Additional parameter value.
        Returns:
        String presentation of the given object.
      • toString

        public static <T> String toString​(Class<T> cls,
                                          T obj,
                                          String name0,
                                          Object val0,
                                          boolean sens0,
                                          String name1,
                                          Object val1,
                                          boolean sens1)
        Produces auto-generated output of string presentation for given object and its declaration class.
        Type Parameters:
        T - Type of the object.
        Parameters:
        cls - Declaration class of the object. Note that this should not be a runtime class.
        obj - Object to get a string presentation for.
        name0 - Additional parameter name.
        val0 - Additional parameter value.
        sens0 - Property sensitive flag.
        name1 - Additional parameter name.
        val1 - Additional parameter value.
        sens1 - Property sensitive flag.
        Returns:
        String presentation of the given object.
      • toString

        public static <T> String toString​(Class<T> cls,
                                          T obj,
                                          String name,
                                          @Nullable
                                          @Nullable Object val)
        Produces auto-generated output of string presentation for given object and its declaration class.
        Type Parameters:
        T - Type of the object.
        Parameters:
        cls - Declaration class of the object. Note that this should not be a runtime class.
        obj - Object to get a string presentation for.
        name - Additional parameter name.
        val - Additional parameter value.
        Returns:
        String presentation of the given object.
      • toString

        public static <T> String toString​(Class<T> cls,
                                          T obj,
                                          String name,
                                          @Nullable
                                          @Nullable Object val,
                                          boolean sens)
        Produces auto-generated output of string presentation for given object and its declaration class.
        Type Parameters:
        T - Type of the object.
        Parameters:
        cls - Declaration class of the object. Note that this should not be a runtime class.
        obj - Object to get a string presentation for.
        name - Additional parameter name.
        val - Additional parameter value.
        sens - Property sensitive flag.
        Returns:
        String presentation of the given object.
      • toString

        public static <T> String toString​(Class<T> cls,
                                          T obj)
        Produces auto-generated output of string presentation for given object and its declaration class.
        Type Parameters:
        T - Type of the object.
        Parameters:
        cls - Declaration class of the object. Note that this should not be a runtime class.
        obj - Object to get a string presentation for.
        Returns:
        String presentation of the given object.
      • toString

        public static <T> String toString​(Class<T> cls,
                                          T obj,
                                          String parent)
        Produces auto-generated output of string presentation for given object and its declaration class.
        Type Parameters:
        T - Type of the object.
        Parameters:
        cls - Declaration class of the object. Note that this should not be a runtime class.
        obj - Object to get a string presentation for.
        parent - String representation of parent.
        Returns:
        String presentation of the given object.
      • toString

        public static String toString​(String str,
                                      String name,
                                      @Nullable
                                      @Nullable Object val)
        Produces uniformed output of string with context properties
        Parameters:
        str - Output prefix or null if empty.
        name - Property name.
        val - Property value.
        Returns:
        String presentation.
      • arrayToString

        public static String arrayToString​(Object arr)
        Returns limited string representation of array.
        Parameters:
        arr - Array object. Each value is automatically wrapped if it has a primitive type.
        Returns:
        String representation of an array.
      • toString

        public static String toString​(String str,
                                      String name,
                                      @Nullable
                                      @Nullable Object val,
                                      boolean sens)
        Produces uniformed output of string with context properties
        Parameters:
        str - Output prefix or null if empty.
        name - Property name.
        val - Property value.
        sens - Property sensitive flag.
        Returns:
        String presentation.
      • toString

        public static String toString​(String str,
                                      String name0,
                                      @Nullable
                                      @Nullable Object val0,
                                      String name1,
                                      @Nullable
                                      @Nullable Object val1)
        Produces uniformed output of string with context properties
        Parameters:
        str - Output prefix or null if empty.
        name0 - Property name.
        val0 - Property value.
        name1 - Property name.
        val1 - Property value.
        Returns:
        String presentation.
      • toString

        public static String toString​(String str,
                                      String name0,
                                      @Nullable
                                      @Nullable Object val0,
                                      boolean sens0,
                                      String name1,
                                      @Nullable
                                      @Nullable Object val1,
                                      boolean sens1)
        Produces uniformed output of string with context properties
        Parameters:
        str - Output prefix or null if empty.
        name0 - Property name.
        val0 - Property value.
        sens0 - Property sensitive flag.
        name1 - Property name.
        val1 - Property value.
        sens1 - Property sensitive flag.
        Returns:
        String presentation.
      • toString

        public static String toString​(String str,
                                      String name0,
                                      @Nullable
                                      @Nullable Object val0,
                                      boolean sens0,
                                      String name1,
                                      @Nullable
                                      @Nullable Object val1,
                                      boolean sens1,
                                      String name2,
                                      @Nullable
                                      @Nullable Object val2,
                                      boolean sens2)
        Produces uniformed output of string with context properties
        Parameters:
        str - Output prefix or null if empty.
        name0 - Property name.
        val0 - Property value.
        sens0 - Property sensitive flag.
        name1 - Property name.
        val1 - Property value.
        sens1 - Property sensitive flag.
        name2 - Property name.
        val2 - Property value.
        sens2 - Property sensitive flag.
        Returns:
        String presentation.
      • toString

        public static String toString​(String str,
                                      String name0,
                                      @Nullable
                                      @Nullable Object val0,
                                      boolean sens0,
                                      String name1,
                                      @Nullable
                                      @Nullable Object val1,
                                      boolean sens1,
                                      String name2,
                                      @Nullable
                                      @Nullable Object val2,
                                      boolean sens2,
                                      String name3,
                                      @Nullable
                                      @Nullable Object val3,
                                      boolean sens3)
        Produces uniformed output of string with context properties
        Parameters:
        str - Output prefix or null if empty.
        name0 - Property name.
        val0 - Property value.
        sens0 - Property sensitive flag.
        name1 - Property name.
        val1 - Property value.
        sens1 - Property sensitive flag.
        name2 - Property name.
        val2 - Property value.
        sens2 - Property sensitive flag.
        name3 - Property name.
        val3 - Property value.
        sens3 - Property sensitive flag.
        Returns:
        String presentation.
      • toString

        public static String toString​(String str,
                                      String name0,
                                      @Nullable
                                      @Nullable Object val0,
                                      boolean sens0,
                                      String name1,
                                      @Nullable
                                      @Nullable Object val1,
                                      boolean sens1,
                                      String name2,
                                      @Nullable
                                      @Nullable Object val2,
                                      boolean sens2,
                                      String name3,
                                      @Nullable
                                      @Nullable Object val3,
                                      boolean sens3,
                                      String name4,
                                      @Nullable
                                      @Nullable Object val4,
                                      boolean sens4)
        Produces uniformed output of string with context properties
        Parameters:
        str - Output prefix or null if empty.
        name0 - Property name.
        val0 - Property value.
        sens0 - Property sensitive flag.
        name1 - Property name.
        val1 - Property value.
        sens1 - Property sensitive flag.
        name2 - Property name.
        val2 - Property value.
        sens2 - Property sensitive flag.
        name3 - Property name.
        val3 - Property value.
        sens3 - Property sensitive flag.
        name4 - Property name.
        val4 - Property value.
        sens4 - Property sensitive flag.
        Returns:
        String presentation.
      • toString

        public static String toString​(String str,
                                      String name0,
                                      @Nullable
                                      @Nullable Object val0,
                                      boolean sens0,
                                      String name1,
                                      @Nullable
                                      @Nullable Object val1,
                                      boolean sens1,
                                      String name2,
                                      @Nullable
                                      @Nullable Object val2,
                                      boolean sens2,
                                      String name3,
                                      @Nullable
                                      @Nullable Object val3,
                                      boolean sens3,
                                      String name4,
                                      @Nullable
                                      @Nullable Object val4,
                                      boolean sens4,
                                      String name5,
                                      @Nullable
                                      @Nullable Object val5,
                                      boolean sens5)
        Produces uniformed output of string with context properties
        Parameters:
        str - Output prefix or null if empty.
        name0 - Property name.
        val0 - Property value.
        sens0 - Property sensitive flag.
        name1 - Property name.
        val1 - Property value.
        sens1 - Property sensitive flag.
        name2 - Property name.
        val2 - Property value.
        sens2 - Property sensitive flag.
        name3 - Property name.
        val3 - Property value.
        sens3 - Property sensitive flag.
        name4 - Property name.
        val4 - Property value.
        sens4 - Property sensitive flag.
        name5 - Property name.
        val5 - Property value.
        sens5 - Property sensitive flag.
        Returns:
        String presentation.
      • toString

        public static String toString​(String str,
                                      String name0,
                                      @Nullable
                                      @Nullable Object val0,
                                      boolean sens0,
                                      String name1,
                                      @Nullable
                                      @Nullable Object val1,
                                      boolean sens1,
                                      String name2,
                                      @Nullable
                                      @Nullable Object val2,
                                      boolean sens2,
                                      String name3,
                                      @Nullable
                                      @Nullable Object val3,
                                      boolean sens3,
                                      String name4,
                                      @Nullable
                                      @Nullable Object val4,
                                      boolean sens4,
                                      String name5,
                                      @Nullable
                                      @Nullable Object val5,
                                      boolean sens5,
                                      String name6,
                                      @Nullable
                                      @Nullable Object val6,
                                      boolean sens6)
        Produces uniformed output of string with context properties
        Parameters:
        str - Output prefix or null if empty.
        name0 - Property name.
        val0 - Property value.
        sens0 - Property sensitive flag.
        name1 - Property name.
        val1 - Property value.
        sens1 - Property sensitive flag.
        name2 - Property name.
        val2 - Property value.
        sens2 - Property sensitive flag.
        name3 - Property name.
        val3 - Property value.
        sens3 - Property sensitive flag.
        name4 - Property name.
        val4 - Property value.
        sens4 - Property sensitive flag.
        name5 - Property name.
        val5 - Property value.
        sens5 - Property sensitive flag.
        name6 - Property name.
        val6 - Property value.
        sens6 - Property sensitive flag.
        Returns:
        String presentation.
      • toString

        public static String toString​(String str,
                                      Object... triplets)
        Produces uniformed output of string with context properties
        Parameters:
        str - Output prefix or null if empty.
        triplets - Triplets {name, value, sencitivity}.
        Returns:
        String presentation.
      • toStringSortedDistinct

        public static String toStringSortedDistinct​(Collection<? extends Comparable<?>> c)
        Creates string representation of a specified collection with preliminary sorting and duplicates removing.
        Parameters:
        c - Input collection.
        Returns:
        String representation of collection.
      • compact

        public static <T extends Number & Comparable<? super T>> String compact​(Collection<T> col,
                                                                                Function<T,​T> nextValFun)
        Returns sorted and compacted string representation of given col. Two nearby numbers are compacted to one continuous segment. E.g. collection of [1, 2, 3, 5, 6, 7, 10] with nextValFun = i -> i + 1 will be compacted to [1-3, 5-7, 10].
        Parameters:
        col - Collection of numbers.
        nextValFun - Function to get nearby number.
        Returns:
        Compacted string representation of given collections.
      • joinToString

        public static <T> String joinToString​(@Nullable
                                              @Nullable Iterable<T> list,
                                              @Nullable
                                              @Nullable String separator,
                                              @Nullable
                                              @Nullable String truncSuffix,
                                              int maxLen,
                                              int maxCnt)
        Creates a string from the elements separated using separator.
        Parameters:
        list - Elements.
        separator - Separator.
        truncSuffix - String suffix in case of string truncation.
        maxLen - Max length of the output string at which it will be truncated (0 - unlimited).
        maxCnt - Max number of added elements at which the string will be truncated (0 - unlimited).
        Returns:
        Result string.