Class ImmutableValue
Value.
Use the builder to create immutable instances:
ImmutableValue.builder().
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic ImmutableValue.Builderbuilder()Creates a builder forImmutableValue.static ImmutableValueCreates an immutable copy of aValuevalue.booleanThis instance is equal to all instances ofImmutableValuethat have equal attribute values.longlonggetFlags()getKey()longlonggetValue()Optional<byte[]>inthashCode()Computes a hash code from attributes:createIndex,modifyIndex,lockIndex,key,flags,value,session.toString()Prints the immutable valueValuewith attribute values.final ImmutableValuewithCreateIndex(long value) Copy the current immutable object by setting a value for thecreateIndexattribute.final ImmutableValuewithFlags(long value) Copy the current immutable object by setting a value for theflagsattribute.final ImmutableValueCopy the current immutable object by setting a value for thekeyattribute.final ImmutableValuewithLockIndex(long value) Copy the current immutable object by setting a value for thelockIndexattribute.final ImmutableValuewithModifyIndex(long value) Copy the current immutable object by setting a value for themodifyIndexattribute.final ImmutableValuewithSession(String value) Copy the current immutable object by setting a present value for the optionalsessionattribute.final ImmutableValuewithSession(Optional<String> optional) Copy the current immutable object by setting an optional value for thesessionattribute.final ImmutableValueCopy the current immutable object by setting a present value for the optionalvalueattribute.final ImmutableValueCopy the current immutable object by setting an optional value for thevalueattribute.Methods inherited from class org.kiwiproject.consul.model.kv.Value
getValueAsString
-
Method Details
-
getCreateIndex
public long getCreateIndex()- Specified by:
getCreateIndexin classValue- Returns:
- The value of the
createIndexattribute
-
getModifyIndex
public long getModifyIndex()- Specified by:
getModifyIndexin classValue- Returns:
- The value of the
modifyIndexattribute
-
getLockIndex
public long getLockIndex()- Specified by:
getLockIndexin classValue- Returns:
- The value of the
lockIndexattribute
-
getKey
-
getFlags
public long getFlags() -
getValue
-
getSession
- Specified by:
getSessionin classValue- Returns:
- The value of the
sessionattribute
-
withCreateIndex
Copy the current immutable object by setting a value for thecreateIndexattribute. A value equality check is used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for createIndex- Returns:
- A modified copy of the
thisobject
-
withModifyIndex
Copy the current immutable object by setting a value for themodifyIndexattribute. A value equality check is used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for modifyIndex- Returns:
- A modified copy of the
thisobject
-
withLockIndex
Copy the current immutable object by setting a value for thelockIndexattribute. A value equality check is used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for lockIndex- Returns:
- A modified copy of the
thisobject
-
withKey
Copy the current immutable object by setting a value for thekeyattribute. An equals check used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for key- Returns:
- A modified copy of the
thisobject
-
withFlags
Copy the current immutable object by setting a value for theflagsattribute. A value equality check is used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for flags- Returns:
- A modified copy of the
thisobject
-
withValue
Copy the current immutable object by setting a present value for the optionalvalueattribute.- Parameters:
value- The value for value- Returns:
- A modified copy of
thisobject
-
withValue
Copy the current immutable object by setting an optional value for thevalueattribute. An equality check is used on inner nullable value to prevent copying of the same value by returningthis.- Parameters:
optional- A value for value- Returns:
- A modified copy of
thisobject
-
withSession
Copy the current immutable object by setting a present value for the optionalsessionattribute.- Parameters:
value- The value for session- Returns:
- A modified copy of
thisobject
-
withSession
Copy the current immutable object by setting an optional value for thesessionattribute. An equality check is used on inner nullable value to prevent copying of the same value by returningthis.- Parameters:
optional- A value for session- Returns:
- A modified copy of
thisobject
-
equals
This instance is equal to all instances ofImmutableValuethat have equal attribute values. -
hashCode
public int hashCode()Computes a hash code from attributes:createIndex,modifyIndex,lockIndex,key,flags,value,session. -
toString
Prints the immutable valueValuewith attribute values. -
getValueAsString
Returns a lazily initialized value of the
valueAsStringattribute. 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:
getValueAsStringin classValue- Returns:
- A lazily initialized value of the
valueAsStringattribute
-
getValueAsBytes
Returns a lazily initialized value of the
valueAsBytesattribute. 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:
getValueAsBytesin classValue- Returns:
- A lazily initialized value of the
valueAsBytesattribute
-
copyOf
Creates an immutable copy of aValuevalue. 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
Creates a builder forImmutableValue.ImmutableValue.builder() .createIndex(long) // requiredcreateIndex.modifyIndex(long) // requiredmodifyIndex.lockIndex(long) // requiredlockIndex.key(String) // requiredkey.flags(long) // requiredflags.value(String) // optionalvalue.session(String) // optionalsession.build();- Returns:
- A new ImmutableValue builder
-