Class DateAttributePredicate

  • All Implemented Interfaces:
    Predicate<ProfileRequestContext>, Predicate<ProfileRequestContext>

    public class DateAttributePredicate
    extends AbstractAttributePredicate
    Provides a date/time matching predicate that compares a date-based attribute value against current system time with optional offset. By convention the predicate returns true if and only if the date represented by the attribute value is after the current system time; false otherwise. Thus the semantics are well-suited for cases such as evaluation of expiration dates.
    • Field Detail

      • log

        @Nonnull
        private final org.slf4j.Logger log
        Class logger.
      • attributeName

        @Nonnull
        @NotEmpty
        private final String attributeName
        Name of attribute to query for.
      • dateTimeFormatter

        @Nullable
        private DateTimeFormatter dateTimeFormatter
        Formatter used to parse string-based date attribute values.
      • legacyFormatter

        @Deprecated
        @Nullable
        private DateTimeFormatter legacyFormatter
        Deprecated.
        Legacy formatter used to parse string-based date attribute values.
      • systemTimeOffset

        @Nonnull
        private Duration systemTimeOffset
        Offset from system time used for date comparisons.
      • resultIfMissing

        private boolean resultIfMissing
        Result of predicate if attribute is missing or has no values.
    • Constructor Detail

      • DateAttributePredicate

        @Deprecated
        public DateAttributePredicate​(@Nonnull @NotEmpty @ParameterName(name="attribute")
                                      String attribute)
        Deprecated.
        Create a new instance that performs date comparisons against the given attribute using ISO date/time format parser by default.

        This is deprecated in favor of the Java 8 API version.

        Parameters:
        attribute - Attribute name that provides candidate date values to test.
      • DateAttributePredicate

        @Deprecated
        public DateAttributePredicate​(@Nonnull @NotEmpty @ParameterName(name="attribute")
                                      String attribute,
                                      @Nonnull @ParameterName(name="formatter")
                                      DateTimeFormatter formatter)
        Deprecated.
        Create a new instance that performs date comparisons against the given attribute using the given date parser.

        This is deprecated in favor of the Java 8 API version.

        Parameters:
        attribute - Attribute name that provides candidate date values to test.
        formatter - Date/time parser.
      • DateAttributePredicate

        public DateAttributePredicate​(@Nonnull @NotEmpty @ParameterName(name="attribute")
                                      String attribute,
                                      @Nonnull @ParameterName(name="formatter")
                                      DateTimeFormatter formatter)
        Create a new instance that performs date comparisons against the given attribute using the given date parser.
        Parameters:
        attribute - Attribute name that provides candidate date values to test.
        formatter - Date/time parser.
      • DateAttributePredicate

        public DateAttributePredicate​(@Nonnull @NotEmpty @ParameterName(name="attribute")
                                      String attribute,
                                      @Nonnull @NotEmpty @ParameterName(name="formatString")
                                      String formatString)
        Create a new instance that performs date comparisons against the given attribute using the given date parser.
        Parameters:
        attribute - Attribute name that provides candidate date values to test.
        formatString - date/time parsing string, currently based on DateTimeFormatter
    • Method Detail

      • setSystemTimeOffset

        @Deprecated
        public void setSystemTimeOffset​(@Nonnull
                                        Duration offset)
        Deprecated.
        Set the system time offset, which affects the reference date for comparisons. By default all comparisons are against system time, i.e. zero offset.
        Parameters:
        offset - System time offset. A negative value decreases the target date (sooner); a positive value increases the target date (later).
      • setOffset

        public void setOffset​(@Nonnull
                              Duration offset)
        Set the system time offset, which affects the reference date for comparisons.

        By default all comparisons are against system time, i.e. zero offset.

        Parameters:
        offset - System time offset. A negative value decreases the target date (sooner); a positive value increases the target date (later).
      • setResultIfMissing

        public void setResultIfMissing​(boolean flag)
        Set the result to return if the attribute to check is missing or has no values.
        Parameters:
        flag - flag to set