Class Versioned<T>
java.lang.Object
org.springframework.vault.support.Versioned<T>
Value object representing versioned secrets along
Versioned.Version
metadata. A versioned
object can hold various states to represent:
- Initial (not yet versioned) secrets via
create(Object)
- Versioned secrets via
create(Object, Version)
- Versioned secrets with
Versioned.Metadata
attachedcreate(Object, Metadata)
Versioned secrets follow a lifecycle that spans from creation to destruction:
- Creation of an unversioned secret: Secret is not yet persisted.
- Versioned secret: Secret is persisted.
- Superseded versioned secret: A newer secret version is stored.
- Deleted versioned secret: Version was deleted. Can be undeleted.
- Destroyed versioned secret: Version was destroyed.
- Since:
- 2.1
- Author:
- Mark Paluch, Jeroen Willemsen
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Value object representing version metadata such as creation/deletion time.static class
Value object representing a Vault version. -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> Versioned<T>
create
(T secret) Create aunversioned
given secret.static <T> Versioned<T>
create
(T secret, Versioned.Metadata metadata) Create a versioned secret object givensecret
andVersioned.Metadata
.static <T> Versioned<T>
create
(T secret, Versioned.Version version) Create a versioned secret object givensecret
andVersioned.Version
.boolean
getData()
Returns the required data for this versioned object.Returns the requiredVersioned.Metadata
for this versioned object.boolean
hasData()
int
hashCode()
boolean
Convert the data element of this versioned object to anOptional
.
-
Method Details
-
create
Create aunversioned
given secret.- Parameters:
secret
- must not be null.- Returns:
- the
Versioned
object forsecret
-
create
Create a versioned secret object givensecret
andVersioned.Version
. Versioned secret may contain no actual data as they can be in a deleted/destroyed state.- Parameters:
secret
- can be null.version
- must not be null.- Returns:
- the
Versioned
object forsecret
andVersion
.
-
create
Create a versioned secret object givensecret
andVersioned.Metadata
. Versioned secret may contain no actual data as they can be in a deleted/destroyed state.- Parameters:
secret
- can be null.metadata
- must not be null.- Returns:
- the
Versioned
object forsecret
andVersioned.Metadata
.
-
getVersion
- Returns:
- the
Versioned.Version
associated with thisVersioned
object.
-
hasMetadata
public boolean hasMetadata()- Returns:
- true if this versioned object has
Versioned.Metadata
associated, otherwisefalse
-
getMetadata
-
getRequiredMetadata
Returns the requiredVersioned.Metadata
for this versioned object. ThrowsIllegalStateException
if no metadata is associated.- Returns:
- the non-null
Versioned.Metadata
held by this for this versioned object. - Throws:
IllegalStateException
- if no metadata is present.
-
hasData
public boolean hasData()- Returns:
- true if this versioned object has data associated, or
false
, of the version is deleted or destroyed.
-
getData
- Returns:
- the actual data for this versioned object. Can be null if the version is deleted or destroyed.
-
getRequiredData
Returns the required data for this versioned object. ThrowsIllegalStateException
if no data is associated.- Returns:
- the non-null value held by this for this versioned object.
- Throws:
IllegalStateException
- if no data is present.
-
toOptional
Convert the data element of this versioned object to anOptional
.- Returns:
Optional
holding the actual value of this versioned object ifdata is present
,Optional.empty()
if no data is associated.
-
equals
-
hashCode
public int hashCode()
-