Class ImmutableKeyValue

java.lang.Object
fr.enedis.chutney.dataset.api.ImmutableKeyValue
All Implemented Interfaces:
KeyValue

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

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

  • Method Details

    • key

      public String key()
      Specified by:
      key in interface KeyValue
      Returns:
      The value of the key attribute
    • value

      public String value()
      Specified by:
      value in interface KeyValue
      Returns:
      The value of the value attribute
    • withKey

      public final ImmutableKeyValue withKey(String value)
      Copy the current immutable object by setting a value for the key attribute. An equals check used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for key
      Returns:
      A modified copy or the this object
    • withValue

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

      public boolean equals(@Nullable Object another)
      This instance is equal to all instances of ImmutableKeyValue 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: key, value.
      Overrides:
      hashCode in class Object
      Returns:
      hashCode value
    • toString

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

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

      public static ImmutableKeyValue.Builder builder()
      Creates a builder for ImmutableKeyValue.
       ImmutableKeyValue.builder()
          .key(String) // required key
          .value(String) // optional value
          .build();
       
      Returns:
      A new ImmutableKeyValue builder