Class ImmutableValue

java.lang.Object
org.kiwiproject.consul.model.kv.Value
org.kiwiproject.consul.model.kv.ImmutableValue

@Generated("org.immutables.processor.ProxyProcessor") public final class ImmutableValue extends Value
Immutable implementation of Value.

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

  • Method Details

    • getCreateIndex

      public long getCreateIndex()
      Specified by:
      getCreateIndex in class Value
      Returns:
      The value of the createIndex attribute
    • getModifyIndex

      public long getModifyIndex()
      Specified by:
      getModifyIndex in class Value
      Returns:
      The value of the modifyIndex attribute
    • getLockIndex

      public long getLockIndex()
      Specified by:
      getLockIndex in class Value
      Returns:
      The value of the lockIndex attribute
    • getKey

      public String getKey()
      Specified by:
      getKey in class Value
      Returns:
      The value of the key attribute
    • getFlags

      public long getFlags()
      Specified by:
      getFlags in class Value
      Returns:
      The value of the flags attribute
    • getValue

      public Optional<String> getValue()
      Specified by:
      getValue in class Value
      Returns:
      The value of the value attribute
    • getSession

      public Optional<String> getSession()
      Specified by:
      getSession in class Value
      Returns:
      The value of the session attribute
    • withCreateIndex

      public final ImmutableValue withCreateIndex(long value)
      Copy the current immutable object by setting a value for the createIndex attribute. A value equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for createIndex
      Returns:
      A modified copy of the this object
    • withModifyIndex

      public final ImmutableValue withModifyIndex(long value)
      Copy the current immutable object by setting a value for the modifyIndex attribute. A value equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for modifyIndex
      Returns:
      A modified copy of the this object
    • withLockIndex

      public final ImmutableValue withLockIndex(long value)
      Copy the current immutable object by setting a value for the lockIndex attribute. A value equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for lockIndex
      Returns:
      A modified copy of the this object
    • withKey

      public final ImmutableValue 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 of the this object
    • withFlags

      public final ImmutableValue withFlags(long value)
      Copy the current immutable object by setting a value for the flags attribute. A value equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for flags
      Returns:
      A modified copy of the this object
    • withValue

      public final ImmutableValue withValue(String value)
      Copy the current immutable object by setting a present value for the optional value attribute.
      Parameters:
      value - The value for value
      Returns:
      A modified copy of this object
    • withValue

      public final ImmutableValue withValue(Optional<String> optional)
      Copy the current immutable object by setting an optional value for the value attribute. An equality check is used on inner nullable value to prevent copying of the same value by returning this.
      Parameters:
      optional - A value for value
      Returns:
      A modified copy of this object
    • withSession

      public final ImmutableValue withSession(String value)
      Copy the current immutable object by setting a present value for the optional session attribute.
      Parameters:
      value - The value for session
      Returns:
      A modified copy of this object
    • withSession

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

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

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

      public Optional<String> getValueAsString()

      Returns a lazily initialized value of the valueAsString attribute. Initialized once and only once and stored for subsequent access with proper synchronization. In case of any exception or error thrown by the lazy value initializer, the result will not be memoised (i.e. remembered) and on next call computation will be attempted again.

      Overrides:
      getValueAsString in class Value
      Returns:
      A lazily initialized value of the valueAsString attribute
    • getValueAsBytes

      public Optional<byte[]> getValueAsBytes()

      Returns a lazily initialized value of the valueAsBytes attribute. Initialized once and only once and stored for subsequent access with proper synchronization. In case of any exception or error thrown by the lazy value initializer, the result will not be memoised (i.e. remembered) and on next call computation will be attempted again.

      Overrides:
      getValueAsBytes in class Value
      Returns:
      A lazily initialized value of the valueAsBytes attribute
    • copyOf

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

      public static ImmutableValue.Builder builder()
      Creates a builder for ImmutableValue.
       ImmutableValue.builder()
          .createIndex(long) // required createIndex
          .modifyIndex(long) // required modifyIndex
          .lockIndex(long) // required lockIndex
          .key(String) // required key
          .flags(long) // required flags
          .value(String) // optional value
          .session(String) // optional session
          .build();
       
      Returns:
      A new ImmutableValue builder