Class ToString

java.lang.Object
software.amazon.awssdk.utils.ToString

@NotThreadSafe public final class ToString extends Object
A class to standardize implementations of Object.toString() across the SDK.

 ToString.builder("Person")
         .add("name", name)
         .add("age", age)
         .build();
 
  • Method Details

    • create

      public static String create(String className)
      Create a to-string result for the given class name.
    • builder

      public static ToString builder(String className)
      Create a to-string result builder for the given class name.
      Parameters:
      className - The name of the class being toString'd
    • add

      public ToString add(String fieldName, Object field)
      Add a field to the to-string result.
      Parameters:
      fieldName - The name of the field. Must not be null.
      field - The value of the field. Value is ignored if null.
    • build

      public String build()
      Convert this result to a string. The behavior of calling other methods after this one is undefined.