Class AttributeHelper

All Implemented Interfaces:
Component, DestructableComponent, IdentifiableComponent, IdentifiedComponent, InitializableComponent

public final class AttributeHelper extends AbstractIdentifiableInitializableComponent
Class to help Attribute Extraction in views.
  • Field Details

    • attributeContextStrategy

      @Nonnull private Function<ProfileRequestContext,AttributeContext> attributeContextStrategy
      How to get the AttributeContext we are looking at.
    • log

      @Nonnull private final org.slf4j.Logger log
      Logger.
  • Constructor Details

    • AttributeHelper

      public AttributeHelper()
  • Method Details

    • setAttributeContextStrategy

      public void setAttributeContextStrategy(@Nonnull Function<ProfileRequestContext,AttributeContext> strategy)
      Set the way to get the AttributeContext.
      Parameters:
      strategy - the strategy to use
    • getFirstAttributeValue

      @Nullable public IdPAttributeValue getFirstAttributeValue(@Nonnull ProfileRequestContext prc, @Nonnull @NotEmpty String attributeName)
      Return the first (filtered) attribute Value from the attribute of that name as an IdPAttributeValue.
      Parameters:
      prc - The ProfileRequestContext
      attributeName - The attribute name to look up
      Returns:
      The attribute value or null
    • getFirstAttributeDisplayValue

      @Nonnull public String getFirstAttributeDisplayValue(@Nonnull ProfileRequestContext prc, @Nonnull @NotEmpty String attributeName, @Nonnull String defaultValue)
      Return the first (filtered) attribute Value from the attribute of that name as a Display String.
      Parameters:
      prc - The ProfileRequestContext
      attributeName - The attribute name to look up
      defaultValue - What to return if nothing found.
      Returns:
      The default value or the attribute value
    • getFirstAttributeDisplayValue

      @Nonnull public String getFirstAttributeDisplayValue(@Nonnull ProfileRequestContext prc, @Nonnull @NotEmpty String attributeName)
      Return the first (filtered) attribute Value from the attribute of that name as a Display String.
      Parameters:
      prc - The ProfileRequestContext
      attributeName - The attribute name to look up
      Returns:
      The attribute value or ""
    • getFirstUnfilteredAttributeValue

      @Nullable public IdPAttributeValue getFirstUnfilteredAttributeValue(@Nonnull ProfileRequestContext prc, @Nonnull @NotEmpty String attributeName)
      Return the first (unfiltered) attribute Value from the attribute of that name as an IdPAttributeValue.
      Parameters:
      prc - The ProfileRequestContext
      attributeName - The attribute name to look up
      Returns:
      The attribute value or null
    • getFirstUnfilteredAttributeDisplayValue

      @Nonnull public String getFirstUnfilteredAttributeDisplayValue(@Nonnull ProfileRequestContext prc, @Nonnull @NotEmpty String attributeName, @Nonnull String defaultValue)
      Return the first (unfiltered) attribute Value from the attribute of that name as a Display String.
      Parameters:
      prc - The ProfileRequestContext
      attributeName - The attribute name to look up
      defaultValue - What to return if nothing found
      Returns:
      The default value or the attribute value
    • getFirstUnfilteredAttributeDisplayValue

      @Nonnull public String getFirstUnfilteredAttributeDisplayValue(@Nonnull ProfileRequestContext prc, @Nonnull @NotEmpty String attributeName)
      Return the first (unfiltered) attribute Value from the attribute of that name as a Display String.
      Parameters:
      prc - The ProfileRequestContext
      attributeName - The attribute name to look up
      Returns:
      The attribute value or ""
    • getFirstValue

      @Nullable private IdPAttributeValue getFirstValue(@Nullable IdPAttribute attribute)
      Helper method to get the first attribute name from the attribute.
      Parameters:
      attribute - the Attribute or null if there wasn't one
      Returns:
      the first attribute value or null