Package org.forgerock.am.cts.api.query
Class PartialToken
- java.lang.Object
-
- org.forgerock.am.cts.api.query.PartialToken
-
public class PartialToken extends Object
Represents a partial CTSToken
. Used to represent the result of a query where only selective attributes of the Token have been requested. Importantly, this is not a full Token and cannot be used as such. The main use case of this PartialToken is an optimisation when requesting data from the CTS and not all fields are required.
-
-
Constructor Summary
Constructors Constructor Description PartialToken(Map<CoreTokenField,Object> entry)
Initialise the PartialToken with the specific fields returned from the query.PartialToken(PartialToken token, CoreTokenField field, Object value)
Copy constructor allowing the caller to modify a field.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
canConvertToToken()
Check if thisPartialToken
can be converted into aToken
.Collection<CoreTokenField>
getFields()
The fields that were included in this query.<T> T
getValue(CoreTokenField field)
Token
toToken()
Converts thisPartialToken
into aToken
containing all of the populated fields.
-
-
-
Constructor Detail
-
PartialToken
public PartialToken(Map<CoreTokenField,Object> entry)
Initialise the PartialToken with the specific fields returned from the query.- Parameters:
entry
- Non null, possibly empty collection.
-
PartialToken
public PartialToken(PartialToken token, CoreTokenField field, Object value)
Copy constructor allowing the caller to modify a field.- Parameters:
token
- The PartialToken to copy. Non null.field
- The field to modify, non null.value
- The value of the field to modify, non null.
-
-
Method Detail
-
getFields
public Collection<CoreTokenField> getFields()
The fields that were included in this query.- Returns:
- A unmodifiable collection of fields.
-
getValue
public <T> T getValue(CoreTokenField field)
- Type Parameters:
T
- The return type, simplifies- Parameters:
field
- The field to return.- Returns:
- The value that was stored or null if this PartialToken does not contain the requested field.
-
canConvertToToken
public boolean canConvertToToken()
Check if thisPartialToken
can be converted into aToken
.- Returns:
- true if this
PartialToken
containsCoreTokenField.TOKEN_ID
andCoreTokenField.TOKEN_TYPE
. - Since:
- 14.0.0
- See Also:
toToken()
-
toToken
public Token toToken()
Converts thisPartialToken
into aToken
containing all of the populated fields.Callers should ensure that this
PartialToken
can be converted by callingcanConvertToToken()
before calling this method.- Returns:
- A
Token
. - Throws:
IllegalStateException
- if thisPartialToken
does not containCoreTokenField.TOKEN_ID
andCoreTokenField.TOKEN_TYPE
.- Since:
- 14.0.0
- See Also:
canConvertToToken()
-
-