Class ImmutableResponse

java.lang.Object
dk.mada.jaxrs.model.api.ImmutableResponse
All Implemented Interfaces:
Response

@Generated(from="Response", generator="Immutables") @Generated("org.immutables.processor.ProxyProcessor") public final class ImmutableResponse extends Object implements Response
Immutable implementation of Response.

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

  • Method Details

    • code

      public StatusCode code()
      Returns the status code of this response.
      Specified by:
      code in interface Response
      Returns:
      the status code of this response
    • content

      public Content content()
      Returns the content of this response.
      Specified by:
      content in interface Response
      Returns:
      the content of this response
    • description

      public Optional<String> description()
      Returns an optional description of this response.
      Specified by:
      description in interface Response
      Returns:
      an optional description of this response
    • withCode

      public final ImmutableResponse withCode(StatusCode value)
      Copy the current immutable object by setting a value for the code attribute. A value equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for code
      Returns:
      A modified copy or the this object
    • withContent

      public final ImmutableResponse withContent(Content value)
      Copy the current immutable object by setting a value for the content attribute. A shallow reference equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for content
      Returns:
      A modified copy or the this object
    • withDescription

      public final ImmutableResponse withDescription(String value)
      Copy the current immutable object by setting a present value for the optional description attribute.
      Parameters:
      value - The value for description
      Returns:
      A modified copy or this if not changed
    • withDescription

      public final ImmutableResponse withDescription(Optional<String> optional)
      Copy the current immutable object by setting an optional value for the description attribute. An equality check is used on inner value to prevent copying of the same value by returning this.
      Parameters:
      optional - An optional value for description
      Returns:
      A modified copy or this if not changed
    • equals

      public boolean equals(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: code, content, description.
      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()
          .code(dk.mada.jaxrs.model.api.StatusCode) // required code
          .content(dk.mada.jaxrs.model.api.Content) // required content
          .description(Optional<String>) // optional description
          .build();
       
      Returns:
      A new ImmutableResponse builder