Class Predicates


  • public class Predicates
    extends java.lang.Object
    Utility class used for creating predicates
    Author:
    Stuart Douglas
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static Predicate and​(Predicate... predicates)
      Creates a predicate that returns true if an only if the given predicates all return true.
      static Predicate authRequired()
      A predicate that returns true if authentication is required
      static Predicate contains​(ExchangeAttribute attribute, java.lang.String... values)
      Returns true if the given attribute is present and contains one of the provided value.
      static Predicate equals​(ExchangeAttribute[] attributes)
      Creates a procedure that returns true if the given ExchangeAttributes are equal.
      static Predicate exists​(ExchangeAttribute attribute)
      Return a predicate that will return true if the given attribute is not null and not empty.
      static Predicate falsePredicate()
      Predicate which always returns false.
      static Predicate maxContentSize​(long size)
      Predicate that returns true if the Content-Size of a request is above a given value.
      static Predicate minContentSize​(long size)
      Predicate that returns true if the Content-Size of a request is below a given value.
      static Predicate not​(Predicate predicate)
      Creates a predicate that returns true if the given predicate returns false.
      static Predicate or​(Predicate... predicates)
      Creates a predicate that returns true if any of the given predicates return true.
      static Predicate parse​(java.lang.String predicate)
      parses the predicate string, and returns the result, using the TCCL to load predicate definitions
      static Predicate parse​(java.lang.String predicate, java.lang.ClassLoader classLoader)
      parses the predicate string, and returns the result
      static Predicate path​(java.lang.String path)
      Creates a predicate that returns true if the given path matches exactly.
      static Predicate paths​(java.lang.String... paths)
      Creates a predicate that returns true if any of the given paths match exactly.
      static Predicate prefix​(java.lang.String path)
      Creates a predicate that returns true if the given relative path starts with the provided prefix.
      static Predicate prefixes​(java.lang.String... paths)
      Creates a predicate that returns true if the relative request path matches any of the provided prefixes.
      static Predicate regex​(ExchangeAttribute attribute, java.lang.String pattern)
      Creates a predicate that matches the given attribute against a regex.
      static Predicate regex​(ExchangeAttribute attribute, java.lang.String pattern, boolean requireFullMatch)
      Creates a predicate that matches the given attribute against a regex.
      static Predicate regex​(java.lang.String attribute, java.lang.String pattern, java.lang.ClassLoader classLoader, boolean requireFullMatch)
      Creates a predicate that matches the given attribute against a regex.
      static Predicate secure()  
      static Predicate suffix​(java.lang.String path)
      Creates a predicate that returns true if the request path ends with the provided suffix.
      static Predicate suffixes​(java.lang.String... paths)
      Creates a predicate that returns true if the request path ends with any of the provided suffixes.
      static Predicate truePredicate()
      Prediction which always returns true
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • equals

        public static Predicate equals​(ExchangeAttribute[] attributes)
        Creates a procedure that returns true if the given ExchangeAttributes are equal.
        Parameters:
        attributes - to be compared in the predictor.
        Returns:
        A new EqualsPredicate.
      • and

        public static Predicate and​(Predicate... predicates)
        Creates a predicate that returns true if an only if the given predicates all return true.
      • or

        public static Predicate or​(Predicate... predicates)
        Creates a predicate that returns true if any of the given predicates return true.
      • not

        public static Predicate not​(Predicate predicate)
        Creates a predicate that returns true if the given predicate returns false.
      • path

        public static Predicate path​(java.lang.String path)
        Creates a predicate that returns true if the given path matches exactly.
      • paths

        public static Predicate paths​(java.lang.String... paths)
        Creates a predicate that returns true if any of the given paths match exactly.
      • suffix

        public static Predicate suffix​(java.lang.String path)
        Creates a predicate that returns true if the request path ends with the provided suffix.
      • suffixes

        public static Predicate suffixes​(java.lang.String... paths)
        Creates a predicate that returns true if the request path ends with any of the provided suffixes.
      • prefix

        public static Predicate prefix​(java.lang.String path)
        Creates a predicate that returns true if the given relative path starts with the provided prefix.
      • prefixes

        public static Predicate prefixes​(java.lang.String... paths)
        Creates a predicate that returns true if the relative request path matches any of the provided prefixes.
      • maxContentSize

        public static Predicate maxContentSize​(long size)
        Predicate that returns true if the Content-Size of a request is above a given value.
      • minContentSize

        public static Predicate minContentSize​(long size)
        Predicate that returns true if the Content-Size of a request is below a given value.
      • truePredicate

        public static Predicate truePredicate()
        Prediction which always returns true
      • falsePredicate

        public static Predicate falsePredicate()
        Predicate which always returns false.
      • exists

        public static Predicate exists​(ExchangeAttribute attribute)
        Return a predicate that will return true if the given attribute is not null and not empty.
        Parameters:
        attribute - The attribute to check whether it exists or not.
      • contains

        public static Predicate contains​(ExchangeAttribute attribute,
                                         java.lang.String... values)
        Returns true if the given attribute is present and contains one of the provided value.
        Parameters:
        attribute - The exchange attribute.
        values - The values to check for.
      • regex

        public static Predicate regex​(ExchangeAttribute attribute,
                                      java.lang.String pattern)
        Creates a predicate that matches the given attribute against a regex. A full match is not required
        Parameters:
        attribute - The exchange attribute to check against.
        pattern - The pattern to look for.
      • regex

        public static Predicate regex​(ExchangeAttribute attribute,
                                      java.lang.String pattern,
                                      boolean requireFullMatch)
        Creates a predicate that matches the given attribute against a regex.
        Parameters:
        requireFullMatch - If a full match is required in order to return true.
        attribute - The attribute to check against.
        pattern - The pattern to look for.
      • regex

        public static Predicate regex​(java.lang.String attribute,
                                      java.lang.String pattern,
                                      java.lang.ClassLoader classLoader,
                                      boolean requireFullMatch)
        Creates a predicate that matches the given attribute against a regex.
        Parameters:
        requireFullMatch - If a full match is required in order to return true.
        attribute - The attribute to check against.
        pattern - The pattern to look for.
      • authRequired

        public static Predicate authRequired()
        A predicate that returns true if authentication is required
        Returns:
        A predicate that returns true if authentication is required
      • parse

        public static Predicate parse​(java.lang.String predicate)
        parses the predicate string, and returns the result, using the TCCL to load predicate definitions
        Parameters:
        predicate - The prediate string
        Returns:
        The predicate
      • parse

        public static Predicate parse​(java.lang.String predicate,
                                      java.lang.ClassLoader classLoader)
        parses the predicate string, and returns the result
        Parameters:
        predicate - The prediate string
        classLoader - The class loader to load the predicates from
        Returns:
        The predicate
      • secure

        public static Predicate secure()
        Returns:
        A predicate that returns true if the request is secure