Class GridToStringBuilder

java.lang.Object
org.apache.ignite.internal.util.tostring.GridToStringBuilder

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):

  • Field Details

    • DFLT_TO_STRING_MAX_LENGTH

      public static final int DFLT_TO_STRING_MAX_LENGTH
      See Also:
    • DFLT_TO_STRING_INCLUDE_SENSITIVE

      public static final boolean DFLT_TO_STRING_INCLUDE_SENSITIVE
      See Also:
    • DFLT_TO_STRING_COLLECTION_LIMIT

      public static final int DFLT_TO_STRING_COLLECTION_LIMIT
      See Also:
  • Constructor Details

    • GridToStringBuilder

      public GridToStringBuilder()
  • Method Details

    • setIncludeSensitiveSupplier

      public static void setIncludeSensitiveSupplier(Supplier<Boolean> sup)
      Setting the logic of the includeSensitive() method.
      By default, it take the value of IGNITE_TO_STRING_INCLUDE_SENSITIVE system property.
      Important! Changing the logic is possible only until the first call of includeSensitive() method.
      Parameters:
      sup -
    • 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:
    • 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, 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, 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, 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, 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, Object val0, String name1, 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, Object val0, boolean sens0, String name1, 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, Object val0, boolean sens0, String name1, Object val1, boolean sens1, String name2, 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, Object val0, boolean sens0, String name1, Object val1, boolean sens1, String name2, Object val2, boolean sens2, String name3, 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, 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 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, 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 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, 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 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.
    • compact

      public static String compact(Collection<Integer> col)
      Returns sorted and compacted string representation of given col. Two nearby numbers with difference at most 1 are compacted to one continuous segment. E.g. collection of [1, 2, 3, 5, 6, 7, 10] will be compacted to [1-3, 5-7, 10].
      Parameters:
      col - Collection of integers.
      Returns:
      Compacted string representation of given collections.
    • 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.