Interface AttributeContainer<T extends AttributeContainer<T>>

All Superinterfaces:
Iterable<Attribute>
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

public interface AttributeContainer<T extends AttributeContainer<T>> extends Iterable<Attribute>
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 Type
    Method
    Description
    append(Iterable<Attribute> attributes)
    Appends the given attribute to a copy of this, returning the result.
    append(Attribute attribute)
    Appends the given attribute to a copy of this, returning the result.
    default boolean
    A flag indicating that this container has an Attribute with the given name.
    default boolean
    A flag indicating that this container has an Attribute with the given name.
    get(String name)
    Get the attribute with the given name if it exists, or null otherwise.
    getAll(String name)
    Get a collection containing all attributes with the given name and distinct authorities.
    Get the value of one of the attributes with the given name, if any exists, or null otherwise.
    default <V> V
    getOptionalValue(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 T
    removeAttribute(String attributeName)
    Remove the top-level attribute with the given name.
    Remove all top-level attributes whose names are in the given Set.
    default T
    retainAttribute(String attributeName)
    Retain only the top-level attribute with the given name.
    Retain all attributes whose names are in the given Set.
    Returns a stream of the Attributes in the container.
    with(Iterable<Attribute> attributes)
    Add the given attributes if not present, or replace the attribute if it already exists.
    with(Attribute attribute)
    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

      T append(Attribute attribute)
      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

      T append(Iterable<Attribute> attributes)
      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

      T with(Attribute attribute)
      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

      T with(Iterable<Attribute> attributes)
      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

      Collection<Attribute> getAll(String name)
      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

      @Nullable default @Nullable Object getOptionalValue(String name)
      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

      @Nullable default <V> V getOptionalValue(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. 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 attribute
      type - type of desired attribute value
      Returns:
      value of one of the attributes with the given name if any, or null otherwise.
    • stream

      Stream<Attribute> stream()
      Returns a stream of the Attributes in the container.
      Returns:
      a Stream of the Attributes contained in the container.
    • contains

      default boolean contains(String name)
      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

      default boolean contains(AttributeName name)
      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

      T removeAttributes(Set<String> exclusions)
      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

      default T removeAttribute(String attributeName)
      Remove the top-level attribute with the given name.
      Parameters:
      attributeName - to remove
      Returns:
      this Attributes without the excluded top-level attribute
    • retainAttributes

      T retainAttributes(Set<String> inclusions)
      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

      default T retainAttribute(String attributeName)
      Retain only the top-level attribute with the given name.
      Parameters:
      attributeName - to keep
      Returns:
      this Attributes with only the included top-level attribute