Class ToStringBuilder

java.lang.Object
com.vaadin.flow.internal.ToStringBuilder

public final class ToStringBuilder extends Object
Builds a toString() value in the SimpleName[?] shape, such as ThemeData[themeName=lumo, variant=dark] or NodeInstallation[/home/user/.vaadin/node-v24.10.0].

The name is the simple name of the runtime class of the described instance, so that a subclass reports its own type. An anonymous class has no simple name, so the closest named superclass is used instead, or the interface it implements when it extends Object directly.

For internal use only. May be renamed or removed in a future release.

Since:
25.4
  • Method Details

    • of

      public static ToStringBuilder of(Object instance)
      Starts building the toString() value of the given instance.
      Parameters:
      instance - the instance to describe, not null
      Returns:
      a new builder, not null
    • add

      public ToStringBuilder add(String name, Object value)
      Adds a value as a name=value pair.
      Parameters:
      name - the name of the value, not null
      value - the value, may be null
      Returns:
      this builder, for chaining
    • addIfNotNull

      public ToStringBuilder addIfNotNull(String name, Object value)
      Adds a value as a name=value pair if it is not null.
      Parameters:
      name - the name of the value, not null
      value - the value, may be null
      Returns:
      this builder, for chaining
    • addValue

      public ToStringBuilder addValue(Object value)
      Adds a value without a name, for a value that is clear without one.
      Parameters:
      value - the value, may be null
      Returns:
      this builder, for chaining
    • toString

      public String toString()
      Overrides:
      toString in class Object