Class Attribute
Object
se.curity.identityserver.sdk.attribute.Attribute
- All Implemented Interfaces:
Iterable<AttributeValue>,AttributeOrAttributeValue<Attribute>
- Direct Known Subclasses:
AuthenticationSessionAttribute,ComplexAttribute
public class Attribute
extends Object
implements AttributeOrAttributeValue<Attribute>, Iterable<AttributeValue>
An Attribute is a collection of
AttributeValues, together with a name and, optionally, an authority.
For the common case where an Attribute has a single value, the methods getValue()
and getAttributeValue() are provided (it is advisable to check first if a value is present
using the collection methods).
Type-safe getters (getValuesOfType(Class) and getValueOfType(Class))
may be used when the type of the attribute is known.
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAttribute(AttributeName name, String authority, AttributeValue value) -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns the attribute's value.getName()<Type> TypegetOptionalValueOfType(Class<Type> type) Returns an optional value of some type.getValue()Retrieves just the attribute's value.<Type> TypegetValueOfType(Class<Type> type) Returns a value of some type.<Type extends Comparable>
List<Type>getValuesOfType(Class<Type> type) Unwraps the values within the AttributeValues of this Attribute, returning all values that are intances of the given type in a Collection.inthashCode()@io.curity.java_to_ts_docs.annotations.TypescriptDocs("This method is meant to be used from Java only!") booleanhasValueOfType(Class<? extends Comparable> type) A flag indicating whether or not the attribute has a value of a certain type.booleanA flag indicating whether or not the attribute has just one value or multiple.iterator()map(String parentPath, AttributeOrAttributeValueTransformer transform) Apply the provided transformation on eachAttributeandAttributeValuein this attribute tree, recursively.static Attributeof(String attributePath, Comparable value) Create an attribute at the given path with the default authority.static Attributeof(String attributePath, Comparable value, String authority) Create an attribute at the given path.static Attributeof(String attributePath, Collection<?> values) Create an attribute at the given path with the default authority.static Attributeof(String attributePath, Collection<?> values, String authority) Create an attribute at the given path.static Attributeof(String attributePath, AttributeValue value) Create an attribute at the given path with the default authority.static Attributeof(String attributePath, AttributeValue value, String authority) Create an attribute at the given path.static Attributeof(AttributeName name, Comparable value) Create an attribute with the given name and the default authority.static Attributeof(AttributeName name, Comparable value, String authority) Create an attribute with the given name.static Attributeof(AttributeName name, Collection<?> values) Create an attribute with the given name and the default authority.static Attributeof(AttributeName name, Collection<?> values, String authority) Create an attribute with the given name.static Attributeof(AttributeName name, AttributeValue value) Create an attribute with the given name and the default authority.static Attributeof(AttributeName name, AttributeValue value, String authority) Create an attribute with the given name.static AttributeCreate an attribute flag at the given path with the default authority.static AttributeofFlag(AttributeName name) Create an attribute flag with the given name and the default authority.stream()toString()withAuthority(String authority) withName(AttributeName name) withValue(Comparable<?> value) withValue(AttributeValue value) Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
NO_AUTHORITY
- See Also:
-
-
Constructor Details
-
Attribute
-
-
Method Details
-
ofFlag
Create an attribute flag at the given path with the default authority.Note: a flag is represented as Attribute with an empty-list value.
- Parameters:
attributePath- full path of the attribute. Notice that the path separator is the dot ('.'), so a path such as `name.familyName` with value 'joe' means, in JSON format:{"name": {"familyName": "joe"}}- Returns:
- Attribute
-
ofFlag
Create an attribute flag with the given name and the default authority.Note: a flag is represented as Attribute with an empty-list value.
- Parameters:
name- of the flag- Returns:
- Attribute
-
of
Create an attribute at the given path with the default authority.- Parameters:
attributePath- full path of the attribute. Notice that the path separator is the dot ('.'), so a path such as `name.familyName` with value 'joe' means, in JSON format:{"name": {"familyName": "joe"}}value- value of the attribute- Returns:
- Attribute
-
of
Create an attribute with the given name and the default authority.- Parameters:
name- of the attributevalue- value of the attribute- Returns:
- Attribute
-
of
Create an attribute at the given path.- Parameters:
attributePath- full path of the attribute. Notice that the path separator is the dot ('.'), so a path such as `name.familyName` with value 'joe' means, in JSON format:{"name": {"familyName": "joe"}}value- value of the attributeauthority- authority- Returns:
- Attribute
-
of
Create an attribute with the given name.- Parameters:
name- of the attributevalue- value of the attributeauthority- authority- Returns:
- Attribute
-
of
Create an attribute at the given path with the default authority.- Parameters:
attributePath- full path of the attribute. Notice that the path separator is the dot ('.'), so a path such as `name.familyName` with value 'joe' means, in JSON format:{"name": {"familyName": "joe"}}values- values of the attribute- Returns:
- Attribute
-
of
Create an attribute with the given name and the default authority.- Parameters:
name- of the attributevalues- values of the attribute- Returns:
- Attribute
-
of
Create an attribute at the given path.- Parameters:
attributePath- full path of the attribute. Notice that the path separator is the dot ('.'), so a path such as `name.familyName` with value 'joe' means, in JSON format:{"name": {"familyName": "joe"}}values- values of the attributeauthority- authority- Returns:
- Attribute
-
of
Create an attribute with the given name.- Parameters:
name- of the attributevalues- values of the attributeauthority- authority- Returns:
- Attribute
-
of
Create an attribute at the given path with the default authority.- Parameters:
attributePath- full path of the attribute. Notice that the path separator is the dot ('.'), so a path such as `name.familyName` with value 'joe' means, in JSON format:{"name": {"familyName": "joe"}}value- value of the attribute- Returns:
- Attribute
-
of
Create an attribute with the given name and the default authority.- Parameters:
name- of the attributevalue- value of the attribute- Returns:
- Attribute
-
of
Create an attribute at the given path.- Parameters:
attributePath- full path of the attribute. Notice that the path separator is the dot ('.'), so a path such as `name.familyName` with value 'joe' means, in JSON format:{"name": {"familyName": "joe"}}value- value of the attributeauthority- authority- Returns:
- Attribute
-
of
Create an attribute with the given name.- Parameters:
name- of the attributevalue- value of the attributeauthority- authority- Returns:
- Attribute
-
map
@Nullable public @Nullable Attribute map(String parentPath, AttributeOrAttributeValueTransformer transform) Description copied from interface:AttributeOrAttributeValueApply the provided transformation on eachAttributeandAttributeValuein this attribute tree, recursively.- Specified by:
mapin interfaceAttributeOrAttributeValue<Attribute>- Parameters:
parentPath- of the current attribute or value being transformed.transform- transformation function.- Returns:
- the transformed attribute or value
-
getName
-
getAuthority
-
getAttributeValue
Returns the attribute's value.- Returns:
- the value of this attribute.
-
isMultiValued
public boolean isMultiValued()A flag indicating whether or not the attribute has just one value or multiple.- Returns:
- true if this Attribute is multi-valued, as opposed to single-valued.
-
hasValueOfType
public @io.curity.java_to_ts_docs.annotations.TypescriptDocs("This method is meant to be used from Java only!") boolean hasValueOfType(Class<? extends Comparable> type) A flag indicating whether or not the attribute has a value of a certain type.- Parameters:
type- of a value- Returns:
- true if this Attribute contains at least one value of the given type, false otherwise.
-
getValue
Retrieves just the attribute's value.- Specified by:
getValuein interfaceAttributeOrAttributeValue<Attribute>- Returns:
- the value of this attribute.
-
getValueWithMetadata
- Specified by:
getValueWithMetadatain interfaceAttributeOrAttributeValue<Attribute>- Returns:
- the value of this entity, including any metadata it might have.
-
getOptionalValueOfType
Returns an optional value of some type.- Type Parameters:
Type- type of the value- Parameters:
type- type of the value- Returns:
- the single value of this attribute, or null if not found.
-
getValueOfType
Returns a value of some type.- Type Parameters:
Type- type of the value- Parameters:
type- type of the value- Returns:
- the single value of this attribute.
- Throws:
NoSuchElementException- if this attribute's value has a different type
-
getValuesOfType
Unwraps the values within the AttributeValues of this Attribute, returning all values that are intances of the given type in a Collection.- Type Parameters:
Type- type of the values- Parameters:
type- type of the values- Returns:
- unwrapped values
-
stream
-
iterator
- Specified by:
iteratorin interfaceIterable<AttributeValue>
-
equals
-
hashCode
public int hashCode() -
toString
-
withValue
-
withValue
-
withName
-
withName
-
withAuthority
-