Package io.vertx.ext.consul
Class KeyValue
- java.lang.Object
-
- io.vertx.ext.consul.KeyValue
-
- All Implemented Interfaces:
TxnResult
public class KeyValue extends Object implements TxnResult
Represents key/value pair stored in Consul- Author:
- Ruslan Sennov
- See Also:
- Consul key/value store
-
-
Constructor Summary
Constructors Constructor Description KeyValue()
Default constructorKeyValue(JsonObject json)
Constructor from JSONKeyValue(KeyValue other)
Copy constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object o)
long
getCreateIndex()
Get the internal index value that represents when the entry was created.long
getFlags()
Get the flags attached to this entry.String
getKey()
Get the keylong
getLockIndex()
Get the number of times this key has successfully been acquired in a lock.long
getModifyIndex()
Get the last index that modified this key.TxnOperationType
getOperationType()
String
getSession()
Get the session that owns the lockString
getValue()
Get the value.int
hashCode()
boolean
isPresent()
Returntrue
if there is a key/value pair present, otherwisefalse
.KeyValue
setCreateIndex(long createIndex)
Set the internal index value that represents when the entry was created.KeyValue
setFlags(long flags)
Set the flags attached to this entry.KeyValue
setKey(String key)
Set the keyKeyValue
setLockIndex(long lockIndex)
Set the number of times this key has successfully been acquired in a lock.KeyValue
setModifyIndex(long modifyIndex)
Set the last index that modified this key.KeyValue
setSession(String session)
Set the session that owns the lockKeyValue
setValue(String value)
Set the valueJsonObject
toJson()
Convert to JSON
-
-
-
Constructor Detail
-
KeyValue
public KeyValue()
Default constructor
-
KeyValue
public KeyValue(KeyValue other)
Copy constructor- Parameters:
other
- the one to copy
-
KeyValue
public KeyValue(JsonObject json)
Constructor from JSON- Parameters:
json
- the JSON
-
-
Method Detail
-
toJson
public JsonObject toJson()
Convert to JSON- Returns:
- the JSON
-
isPresent
public boolean isPresent()
Returntrue
if there is a key/value pair present, otherwisefalse
.- Returns:
true
if there is a key/value pair present, otherwisefalse
-
getKey
public String getKey()
Get the key- Returns:
- the key
-
setKey
public KeyValue setKey(String key)
Set the key- Parameters:
key
- the key- Returns:
- reference to this, for fluency
-
getValue
public String getValue()
Get the value. In case if KeyValue is result of transaction, value can be empty- Returns:
- the value
-
setValue
public KeyValue setValue(String value)
Set the value- Parameters:
value
- the value- Returns:
- reference to this, for fluency
-
getSession
public String getSession()
Get the session that owns the lock- Returns:
- the session that owns the lock
-
setSession
public KeyValue setSession(String session)
Set the session that owns the lock- Parameters:
session
- the session that owns the lock- Returns:
- reference to this, for fluency
-
getFlags
public long getFlags()
Get the flags attached to this entry. Clients can choose to use this however makes sense for their application.- Returns:
- the flags attached to this entry
-
setFlags
public KeyValue setFlags(long flags)
Set the flags attached to this entry. Clients can choose to use this however makes sense for their application.- Parameters:
flags
- the flags attached to this entry. Clients can choose to use this however makes sense for their application.- Returns:
- reference to this, for fluency
-
getCreateIndex
public long getCreateIndex()
Get the internal index value that represents when the entry was created.- Returns:
- the internal index value that represents when the entry was created.
-
setCreateIndex
public KeyValue setCreateIndex(long createIndex)
Set the internal index value that represents when the entry was created.- Parameters:
createIndex
- the internal index value that represents when the entry was created.- Returns:
- reference to this, for fluency
-
getModifyIndex
public long getModifyIndex()
Get the last index that modified this key.- Returns:
- the last index that modified this key.
-
setModifyIndex
public KeyValue setModifyIndex(long modifyIndex)
Set the last index that modified this key.- Parameters:
modifyIndex
- the last index that modified this key.- Returns:
- reference to this, for fluency
-
getLockIndex
public long getLockIndex()
Get the number of times this key has successfully been acquired in a lock.- Returns:
- the number of times this key has successfully been acquired in a lock.
-
setLockIndex
public KeyValue setLockIndex(long lockIndex)
Set the number of times this key has successfully been acquired in a lock.- Parameters:
lockIndex
- the number of times this key has successfully been acquired in a lock.- Returns:
- reference to this, for fluency
-
getOperationType
public TxnOperationType getOperationType()
- Specified by:
getOperationType
in interfaceTxnResult
-
-