Class ImmutableAnswer

java.lang.Object
io.dialob.api.questionnaire.ImmutableAnswer
All Implemented Interfaces:
Answer, Serializable

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

Use the builder to create immutable instances: ImmutableAnswer.builder(). Use the static factory method to create immutable instances: ImmutableAnswer.of().

See Also:
  • Method Details

    • getId

      public String getId()
      Specified by:
      getId in interface Answer
      Returns:
      The value of the id attribute
    • getValue

      public Object getValue()
      Text and number field answers stored in orignal format
      Specified by:
      getValue in interface Answer
      Returns:
      user's answer in original format
    • getType

      public String getType()
      Specified by:
      getType in interface Answer
      Returns:
      The value of the type attribute
    • getAcceptedValue

      public Object getAcceptedValue()
      Specified by:
      getAcceptedValue in interface Answer
      Returns:
      The value of the acceptedValue attribute
    • getUpdated

      public Date getUpdated()
      Specified by:
      getUpdated in interface Answer
      Returns:
      The value of the updated attribute
    • getUserId

      public String getUserId()
      Specified by:
      getUserId in interface Answer
      Returns:
      The value of the userId attribute
    • withId

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

      public final ImmutableAnswer withValue(Object value)
      Copy the current immutable object by setting a value for the value attribute. A shallow reference equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for value (can be null)
      Returns:
      A modified copy of the this object
    • withType

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

      public final ImmutableAnswer withAcceptedValue(Object value)
      Copy the current immutable object by setting a value for the acceptedValue attribute. A shallow reference equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for acceptedValue (can be null)
      Returns:
      A modified copy of the this object
    • withUpdated

      public final ImmutableAnswer withUpdated(Date value)
      Copy the current immutable object by setting a value for the updated attribute. A shallow reference equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for updated (can be null)
      Returns:
      A modified copy of the this object
    • withUserId

      public final ImmutableAnswer withUserId(String value)
      Copy the current immutable object by setting a value for the userId attribute. An equals check used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for userId (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 ImmutableAnswer 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: id, value, type, acceptedValue, updated, userId.
      Overrides:
      hashCode in class Object
      Returns:
      hashCode value
    • toString

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

      public static ImmutableAnswer of(String id, Object value)
      Construct a new immutable Answer instance.
      Parameters:
      id - The value for the id attribute
      value - The value for the value attribute
      Returns:
      An immutable Answer instance
    • copyOf

      public static ImmutableAnswer copyOf(Answer instance)
      Creates an immutable copy of a Answer 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 Answer instance
    • builder

      public static ImmutableAnswer.Builder builder()
      Creates a builder for ImmutableAnswer.
       ImmutableAnswer.builder()
          .id(String | null) // nullable id
          .value(Object | null) // nullable value
          .type(String | null) // nullable type
          .acceptedValue(Object | null) // nullable acceptedValue
          .updated(Date | null) // nullable updated
          .userId(String | null) // nullable userId
          .build();
       
      Returns:
      A new ImmutableAnswer builder