Class DateTimeAttributeDefinition

All Implemented Interfaces:
AttributeDefinition, ResolverPlugin<IdPAttribute>, Component, DestructableComponent, IdentifiableComponent, IdentifiedComponent, InitializableComponent, UnmodifiableComponent, DisposableBean

@ThreadSafe public class DateTimeAttributeDefinition extends AbstractAttributeDefinition
An AttributeDefinition that creates an attribute whose values are the values of all its dependencies, passed through or converted into a DateTimeAttributeValue.

Values already of this type are simple passed through, while StringAttributeValue objects are converted. It is optional whether to omit incompatible values or raise an error.

Since:
4.3.0
  • Field Details

    • log

      @Nonnull private org.slf4j.Logger log
      Class logger.
    • formatter

      @Nullable private DateTimeFormatter formatter
      Formatter for string to date/time conversion.
    • epochInSeconds

      private boolean epochInSeconds
      Convert numeric strings into epoch as seconds.
    • ignoreConversionErrors

      private boolean ignoreConversionErrors
      Do we ignore converstion failures?
  • Constructor Details

    • DateTimeAttributeDefinition

      public DateTimeAttributeDefinition()
      Constructor.
  • Method Details

    • setEpochInSeconds

      public void setEpochInSeconds(boolean flag)
      Set whether to convert numeric string data into an epoch using seconds instead of milliseconds.

      Defaults to true.

      Parameters:
      flag -
    • isEpochInSeconds

      public boolean isEpochInSeconds()
      Get whether to convert numeric string data into an epoch using seconds instead of milliseconds.
      Returns:
      true iff epoch conversion should be based on seconds
    • setIgnoreConversionErrors

      public void setIgnoreConversionErrors(boolean flag)
      Set whether to ignore conversion failures.
      Parameters:
      flag - flag to set
    • isIgnoreConversionErrors

      public boolean isIgnoreConversionErrors()
      Get whether to ignore conversion failures.
      Returns:
      whether to ignore conversion failures
    • setDateTimeFormatter

      public void setDateTimeFormatter(@Nullable DateTimeFormatter f)
      Set a formatter to use to convert string data into an Instant.
      Parameters:
      f - formatter
    • getDateTimeFormatter

      @Nullable public DateTimeFormatter getDateTimeFormatter()
      Get the formatter to use to convert string data into an Instant.
      Returns:
      formatter
    • doInitialize

      protected void doInitialize() throws ComponentInitializationException
      Overrides:
      doInitialize in class AbstractAttributeDefinition
      Throws:
      ComponentInitializationException
    • doAttributeDefinitionResolve

      @Nonnull protected IdPAttribute doAttributeDefinitionResolve(@Nonnull AttributeResolutionContext resolutionContext, @Nonnull AttributeResolverWorkContext workContext) throws ResolutionException
      Creates and populates the values for the resolved attribute. Implementations should not set, or otherwise manage, the resolved attribute's display name, description or encoders. Nor should the resultant attribute be recorded in the given resolution context.
      Specified by:
      doAttributeDefinitionResolve in class AbstractAttributeDefinition
      Parameters:
      resolutionContext - current attribute resolution context
      workContext - current resolver work context
      Returns:
      resolved attribute or null if nothing to resolve.
      Throws:
      ResolutionException - thrown if there is a problem resolving and creating the attribute
    • convert

      @Nullable protected DateTimeAttributeValue convert(@Nonnull IdPAttributeValue input)
      Convert an input value into a DateTimeAttributeValue if possible.
      Parameters:
      input - input value
      Returns:
      converted value or null