Package com.orbitz.consul.model.kv
Class ImmutableValue
- java.lang.Object
-
- com.orbitz.consul.model.kv.Value
-
- com.orbitz.consul.model.kv.ImmutableValue
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classImmutableValue.BuilderBuilds instances of typeImmutableValue.
-
Method Summary
Modifier and Type Method Description static ImmutableValue.Builderbuilder()Creates a builder forImmutableValue.static ImmutableValuecopyOf(Value instance)Creates an immutable copy of aValuevalue.booleanequals(java.lang.Object another)This instance is equal to all instances ofImmutableValuethat have equal attribute values.longgetCreateIndex()longgetFlags()java.lang.StringgetKey()longgetLockIndex()longgetModifyIndex()java.util.Optional<java.lang.String>getSession()java.util.Optional<java.lang.String>getValue()java.util.Optional<byte[]>getValueAsBytes()java.util.Optional<java.lang.String>getValueAsString()inthashCode()Computes a hash code from attributes:createIndex,modifyIndex,lockIndex,key,flags,value,session.java.lang.StringtoString()Prints the immutable valueValuewith attribute values.ImmutableValuewithCreateIndex(long value)Copy the current immutable object by setting a value for thecreateIndexattribute.ImmutableValuewithFlags(long value)Copy the current immutable object by setting a value for theflagsattribute.ImmutableValuewithKey(java.lang.String value)Copy the current immutable object by setting a value for thekeyattribute.ImmutableValuewithLockIndex(long value)Copy the current immutable object by setting a value for thelockIndexattribute.ImmutableValuewithModifyIndex(long value)Copy the current immutable object by setting a value for themodifyIndexattribute.ImmutableValuewithSession(java.lang.String value)Copy the current immutable object by setting a present value for the optionalsessionattribute.ImmutableValuewithSession(java.util.Optional<java.lang.String> optional)Copy the current immutable object by setting an optional value for thesessionattribute.ImmutableValuewithValue(java.lang.String value)Copy the current immutable object by setting a present value for the optionalvalueattribute.ImmutableValuewithValue(java.util.Optional<java.lang.String> optional)Copy the current immutable object by setting an optional value for thevalueattribute.-
Methods inherited from class com.orbitz.consul.model.kv.Value
getValueAsString
-
-
-
-
Method Detail
-
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
public java.lang.String getKey()
-
getFlags
public long getFlags()
-
getValue
public java.util.Optional<java.lang.String> getValue()
-
getSession
public java.util.Optional<java.lang.String> getSession()
- Specified by:
getSessionin classValue- Returns:
- The value of the
sessionattribute
-
withCreateIndex
public final ImmutableValue withCreateIndex(long value)
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
public final ImmutableValue withModifyIndex(long value)
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
public final ImmutableValue withLockIndex(long value)
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
public final ImmutableValue withKey(java.lang.String value)
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
public final ImmutableValue withFlags(long value)
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
public final ImmutableValue withValue(java.lang.String value)
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
public final ImmutableValue withValue(java.util.Optional<java.lang.String> optional)
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
public final ImmutableValue withSession(java.lang.String value)
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
public final ImmutableValue withSession(java.util.Optional<java.lang.String> optional)
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
public boolean equals(@Nullable java.lang.Object another)This instance is equal to all instances ofImmutableValuethat have equal attribute values.- Overrides:
equalsin classjava.lang.Object- Returns:
trueifthisis equal toanotherinstance
-
hashCode
public int hashCode()
Computes a hash code from attributes:createIndex,modifyIndex,lockIndex,key,flags,value,session.- Overrides:
hashCodein classjava.lang.Object- Returns:
- hashCode value
-
toString
public java.lang.String toString()
Prints the immutable valueValuewith attribute values.- Overrides:
toStringin classjava.lang.Object- Returns:
- A string representation of the value
-
getValueAsString
public java.util.Optional<java.lang.String> 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
public java.util.Optional<byte[]> 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
public static ImmutableValue copyOf(Value instance)
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
public static ImmutableValue.Builder 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
-
-