Class MapAttributeValue
Object
se.curity.identityserver.sdk.attribute.MapAttributeValue
- All Implemented Interfaces:
Iterable<Attribute>,AttributeContainer<MapAttributeValue>,AttributeOrAttributeValue<AttributeValue>,AttributeValue
- Direct Known Subclasses:
AuthorizationActionAttributes,AuthorizationResourceAttributes,ComplexAttributeValue,ContextAttributes,Meta,Name,SubjectAttributes
public class MapAttributeValue
extends Object
implements AttributeValue, AttributeContainer<MapAttributeValue>
An
AttributeValue representing multiple Attribute instances, similar to a Map where the keys
are the names of the attributes, and the values the Attributes themselves.
Since version 5.0.0, instances of this class can contain multiple attributes with the same name,
as long as they have distinct authorities. However, some accessor methods will only expose one of them
(e.g. get(String).
-
Constructor Summary
Constructors -
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.booleanGet 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.Returns aMapwhere the keys are attribute names and the values are attributes.<T extends Comparable<T>>
TgetMandatory(Class<T> type, String... pathParts) getValue()Returns a map-based representation of the attribute value allowing for multiple nested attributes with the same name and different authorities.inthashCode()booleanisEmpty()iterator()keys()protected static <T,R> R protected static <T,R> R map(@Nullable T value, NullableFunction<T, R> transform) map(String path, AttributeOrAttributeValueTransformer transform) Apply the provided transformation on eachAttributeandAttributeValuein this attribute tree, recursively.mapEntries(String path, AttributeOrAttributeValueTransformer transform) Maps all the entries of thisMapAttributeValuerecursively.Maps the entries of this Map without recursion into each entry.protected static <T> TnullOrOfType(Class<T> type, @Nullable Object object) static MapAttributeValuestatic MapAttributeValuestatic MapAttributeValueCreate aMapAttributeValueobject from aMap.removeAttributes(Set<String> exclusionNames) Remove all top-level attributes whose names are in the given Set.retainAttributes(Set<String> inclusionNames) Retain all attributes whose names are in the given Set.intsize()stream()Returns a stream of the Attributes in the container.toString()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 class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface se.curity.identityserver.sdk.attribute.AttributeContainer
contains, contains, getOptionalValue, getOptionalValue, removeAttribute, retainAttributeMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
MapAttributeValue
-
-
Method Details
-
nullOrOfType
-
map
-
map
-
of
-
of
Create aMapAttributeValueobject from aMap.- Parameters:
map- the attribute values to create an map of attribute values fromnameFormat- the format of the name- Returns:
- the new
MapAttributeValueobject - Since:
- 2.1.0
- See Also:
-
of
-
getValue
- Specified by:
getValuein interfaceAttributeOrAttributeValue<AttributeValue>- Returns:
- the value of this entity.
-
getValueWithMetadata
- Specified by:
getValueWithMetadatain interfaceAttributeOrAttributeValue<AttributeValue>- Returns:
- the value of this entity, including any metadata it might have.
-
getValueWithAuthorities
Returns a map-based representation of the attribute value allowing for multiple nested attributes with the same name and different authorities. The format is the following:- Each attribute is represented by an entry with key:
<attribute-full-name>@<attribute-authority>. If the attribute doesn't have an authority, then the key is just<attribute-full-name> - There is an additional {code @authorities} key, whose value is a map. Each entry in that inner map corresponds to an attribute name, and its value is a list of all authorities for attributes with that name.
As an example, this is the JSON representation of the map produced by an instance containing two attribute named
the-nameand having authoritiesauthority1andauthority2{ "the-name@authority1": ..., "the-name@authority2": ..., "@authorities": { "the-name": ["authority1", "authority2"] } }- Specified by:
getValueWithAuthoritiesin interfaceAttributeValue- Returns:
- a representation of the attribute value allowing for multiple nested attributes with the same name and different authorities.
- Each attribute is represented by an entry with key:
-
getAttributesByName
Returns aMapwhere the keys are attribute names and the values are attributes. If there are multiple attributes with the same name, then only one of them is returned.- Returns:
- a
Mapfrom attribute name to attribute.
-
size
public int size() -
isEmpty
public boolean isEmpty()- Specified by:
isEmptyin interfaceAttributeValue- Returns:
- true if this AttributeValue is semantically empty, ie. has no value.
-
keys
-
append
Description copied from interface:AttributeContainerAppends the given attribute to a copy of this, returning the result.- Specified by:
appendin interfaceAttributeContainer<MapAttributeValue>- Parameters:
attribute- to append- Returns:
- copy of this with the provided attribute appended to it
-
append
Description copied from interface:AttributeContainerAppends the given attribute to a copy of this, returning the result.- Specified by:
appendin interfaceAttributeContainer<MapAttributeValue>- Parameters:
attributes- to append- Returns:
- copy of this with the provided attribute appended to it
-
with
Description copied from interface:AttributeContainerAdd 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.- Specified by:
within interfaceAttributeContainer<MapAttributeValue>- Parameters:
attribute- attribute to add or to override- Returns:
- a copy of this which contains the given Attribute
-
with
Description copied from interface:AttributeContainerAdd 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.- Specified by:
within interfaceAttributeContainer<MapAttributeValue>- Parameters:
attributes- attribute to add or to override- Returns:
- a copy of this which contains the given Attributes
-
get
Description copied from interface:AttributeContainerGet 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.- Specified by:
getin interfaceAttributeContainer<MapAttributeValue>- Parameters:
name- of attribute- Returns:
- one of the attributes with the given name if any, or null otherwise.
-
getAll
Description copied from interface:AttributeContainerGet a collection containing all attributes with the given name and distinct authorities.- Specified by:
getAllin interfaceAttributeContainer<MapAttributeValue>- Parameters:
name- of attribute- Returns:
- an unmodifiable collection with all the contained attributes with the given name.
-
stream
Description copied from interface:AttributeContainerReturns a stream of the Attributes in the container.- Specified by:
streamin interfaceAttributeContainer<MapAttributeValue>- Returns:
- a Stream of the Attributes contained in the container.
-
iterator
-
mapNonRecursive
Maps the entries of this Map without recursion into each entry.To use recursion, use the
mapEntries(String, AttributeOrAttributeValueTransformer)method.- Parameters:
transform- transformation function- Returns:
- the transformed Map
-
map
@Nullable public @Nullable AttributeValue map(String path, AttributeOrAttributeValueTransformer transform) Description copied from interface:AttributeOrAttributeValueApply the provided transformation on eachAttributeandAttributeValuein this attribute tree, recursively.- Specified by:
mapin interfaceAttributeOrAttributeValue<AttributeValue>- Specified by:
mapin interfaceAttributeValue- Parameters:
path- of the current attribute or value being transformed.transform- transformation function.- Returns:
- the transformed attribute or value
-
mapEntries
Maps all the entries of thisMapAttributeValuerecursively.This method is similar to the
map(String, AttributeOrAttributeValueTransformer)method, but it may not be used to transform the Map itself, hence it always return a non-nullMapAttributeValue.- Parameters:
path- of the roottransform- transformation function.- Returns:
- the transformed Map
-
getMandatory
- Throws:
NoSuchElementException- if mandatory attributes are missing
-
get
-
removeNullAttributeValues
- Returns:
- a copy of this containing no instances of
NullAttributeValue.
-
removeAttributes
Description copied from interface:AttributeContainerRemove all top-level attributes whose names are in the given Set.- Specified by:
removeAttributesin interfaceAttributeContainer<MapAttributeValue>- Parameters:
exclusionNames- names of attributes to exclude.- Returns:
- this Attributes without the excluded top-level attributes
-
retainAttributes
Description copied from interface:AttributeContainerRetain all attributes whose names are in the given Set. All attributes that are not named in the set are removed.- Specified by:
retainAttributesin interfaceAttributeContainer<MapAttributeValue>- Parameters:
inclusionNames- names of attributes to retain.- Returns:
- this Attributes with only the included attributes
-
equals
-
hashCode
public int hashCode() -
delete
-
toString
-