Interface AttributeContainer<T extends AttributeContainer<T>>
- All Known Implementing Classes:
AccountAttributes,Address,AttributeAdditions,AttributeReplacements,Attributes,AuthenticationAttributes,AuthorizationActionAttributes,AuthorizationAttributes,AuthorizationResourceAttributes,ComplexAttributeValue,ConsentAttributes,ConsentorResultAttributes,ContextAttributes,Device,DeviceAttributes,DynamicallyRegisteredClientAttributes,Email,Entitlement,GraphQLAuthorizationActionAttributes,GraphQLAuthorizationResourceAttributes,Group,InstantMessaging,LinkedAccount,MapAttributeValue,Meta,MultiValuedAttributeValue,Name,OAuthAuthorizationActionAttributes,OAuthAuthorizationResourceAttributes,PhoneNumber,Photo,ResourceAttributes,Role,ScimAuthorizationActionAttributes,ScimAuthorizationResourceAttributes,SubjectAttributes,TokenAttributes,X509Certificates
A immutable container of
Attribute instances which allows appending.
Since version 5.0.0, attribute containers can have multiple attributes with the same name,
as long as the authorities are distinct.
-
Method Summary
Modifier and TypeMethodDescriptionAppends the given attribute to a copy of this, returning the result.Appends the given attribute to a copy of this, returning the result.default booleanA flag indicating that this container has an Attribute with the given name.default booleancontains(AttributeName name) A flag indicating that this container has an Attribute with the given name.Get the attribute with the given name if it exists, or null otherwise.Get a collection containing all attributes with the given name and distinct authorities.getOptionalValue(String name) Get the value of one of the attributes with the given name, if any exists, or null otherwise.default <V> VgetOptionalValue(String name, Class<V> type) Get the value of one of the attributes with the given name if any exists AND has the given type, or null otherwise.default TremoveAttribute(String attributeName) Remove the top-level attribute with the given name.removeAttributes(Set<String> exclusions) Remove all top-level attributes whose names are in the given Set.default TretainAttribute(String attributeName) Retain only the top-level attribute with the given name.retainAttributes(Set<String> inclusions) Retain all attributes whose names are in the given Set.stream()Returns a stream of the Attributes in the container.Add the given attributes if not present, or replace the attribute if it already exists.Add the given attribute if not present, or replace the attribute if it already exists.Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
Method Details
-
append
Appends the given attribute to a copy of this, returning the result.- Parameters:
attribute- to append- Returns:
- copy of this with the provided attribute appended to it
- Throws:
IllegalArgumentException- if an attribute with the same name and authority already exists in this instance.
-
append
Appends the given attribute to a copy of this, returning the result.- Parameters:
attributes- to append- Returns:
- copy of this with the provided attribute appended to it
- Throws:
IllegalArgumentException- if an attribute with the same name and authority already exists in this instance.
-
with
Add the given attribute if not present, or replace the attribute if it already exists. Note that two attributes with the same name and different authorities are considered distinct.- Parameters:
attribute- attribute to add or to override- Returns:
- a copy of this which contains the given Attribute
-
with
Add the given attributes if not present, or replace the attribute if it already exists. Note that two attributes with the same name and different authorities are considered distinct.- Parameters:
attributes- attribute to add or to override- Returns:
- a copy of this which contains the given Attributes
-
get
Get the attribute with the given name if it exists, or null otherwise. If multiple attributes with the same name exist (e.g. with different authorities), then one of those attributes will be returned.- Parameters:
name- of attribute- Returns:
- one of the attributes with the given name if any, or null otherwise.
-
getAll
Get a collection containing all attributes with the given name and distinct authorities.- Parameters:
name- of attribute- Returns:
- an unmodifiable collection with all the contained attributes with the given name.
- Since:
- 5.0.0
-
getOptionalValue
Get the value of one of the attributes with the given name, if any exists, or null otherwise. If multiple attributes with the same name exist (e.g. with different authorities), then the value of one of those attributes will be returned.- Parameters:
name- of attribute- Returns:
- value of one of the attributes with the given name if any, or null otherwise.
-
getOptionalValue
Get the value of one of the attributes with the given name if any exists AND has the given type, or null otherwise. If multiple attributes with the same name exist (e.g. with different authorities), then the value of one of those attributes will be returned.- Type Parameters:
V- type of value to return- Parameters:
name- of attributetype- type of desired attribute value- Returns:
- value of one of the attributes with the given name if any, or null otherwise.
-
stream
Returns a stream of the Attributes in the container.- Returns:
- a Stream of the Attributes contained in the container.
-
contains
A flag indicating that this container has an Attribute with the given name.- Parameters:
name- attribute name- Returns:
- true if an attribute with the given name exists, false otherwise.
-
contains
A flag indicating that this container has an Attribute with the given name.- Parameters:
name- attribute name- Returns:
- true if an attribute with the given name exists, false otherwise.
-
removeAttributes
Remove all top-level attributes whose names are in the given Set.- Parameters:
exclusions- names of attributes to exclude.- Returns:
- this Attributes without the excluded top-level attributes
-
removeAttribute
Remove the top-level attribute with the given name.- Parameters:
attributeName- to remove- Returns:
- this Attributes without the excluded top-level attribute
-
retainAttributes
Retain all attributes whose names are in the given Set. All attributes that are not named in the set are removed.- Parameters:
inclusions- names of attributes to retain.- Returns:
- this Attributes with only the included attributes
-
retainAttribute
Retain only the top-level attribute with the given name.- Parameters:
attributeName- to keep- Returns:
- this Attributes with only the included top-level attribute
-