Class ImmutableResponse

java.lang.Object
io.dialob.api.rest.ImmutableResponse
All Implemented Interfaces:
Response, ResponseStatus, Serializable

@ParametersAreNonnullByDefault @Generated("org.immutables.processor.ProxyProcessor") @Immutable public final class ImmutableResponse extends Object implements Response
Immutable implementation of Response.

Use the builder to create immutable instances: ImmutableResponse.builder().

See Also:
  • Method Details

    • getOk

      public Boolean getOk()
      Specified by:
      getOk in interface ResponseStatus
      Returns:
      The value of the ok attribute
    • getError

      public String getError()
      Specified by:
      getError in interface Response
      Returns:
      The value of the error attribute
    • getReason

      public String getReason()
      Specified by:
      getReason in interface Response
      Returns:
      The value of the reason attribute
    • withOk

      public final ImmutableResponse withOk(Boolean value)
      Copy the current immutable object by setting a value for the ok attribute. An equals check used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for ok (can be null)
      Returns:
      A modified copy of the this object
    • withError

      public final ImmutableResponse withError(String value)
      Copy the current immutable object by setting a value for the error attribute. An equals check used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for error (can be null)
      Returns:
      A modified copy of the this object
    • withReason

      public final ImmutableResponse withReason(String value)
      Copy the current immutable object by setting a value for the reason attribute. An equals check used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for reason (can be null)
      Returns:
      A modified copy of the this object
    • equals

      public boolean equals(@Nullable Object another)
      This instance is equal to all instances of ImmutableResponse that have equal attribute values.
      Overrides:
      equals in class Object
      Returns:
      true if this is equal to another instance
    • hashCode

      public int hashCode()
      Computes a hash code from attributes: ok, error, reason.
      Overrides:
      hashCode in class Object
      Returns:
      hashCode value
    • toString

      public String toString()
      Prints the immutable value Response with attribute values.
      Overrides:
      toString in class Object
      Returns:
      A string representation of the value
    • copyOf

      public static ImmutableResponse copyOf(Response instance)
      Creates an immutable copy of a Response value. Uses accessors to get values to initialize the new immutable instance. If an instance is already immutable, it is returned as is.
      Parameters:
      instance - The instance to copy
      Returns:
      A copied immutable Response instance
    • builder

      public static ImmutableResponse.Builder builder()
      Creates a builder for ImmutableResponse.
       ImmutableResponse.builder()
          .ok(Boolean | null) // nullable ok
          .error(String | null) // nullable error
          .reason(String | null) // nullable reason
          .build();
       
      Returns:
      A new ImmutableResponse builder