Class Matcher<T>

  • Type Parameters:
    T - the enclosing type of the objects that match

    public abstract class Matcher<T>
    extends java.lang.Object
    A matching object that can be used to filter the node-set in a context query chain.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.lang.Class<T> boundType  
    • Constructor Summary

      Constructors 
      Constructor Description
      Matcher()  
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      private static <T extends Matcher<?>>
      java.lang.Class<?>
      getSafeType​(java.lang.Class<T> fromClass)  
      boolean matches​(java.lang.Object object)
      Returns true if this object matches successfully.
      protected abstract boolean matchesSafely​(T object)
      Returns true if the supplied object matches against this matcher.
      • Methods inherited from class java.lang.Object

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

      • boundType

        private final java.lang.Class<T> boundType
    • Constructor Detail

      • Matcher

        public Matcher()
    • Method Detail

      • getSafeType

        private static <T extends Matcher<?>> java.lang.Class<?> getSafeType​(java.lang.Class<T> fromClass)
      • matches

        public final boolean matches​(java.lang.Object object)
        Returns true if this object matches successfully.

        This method checks for a type match against the erased type of this matcher and then defers to the matchesSafely(Object) of this matcher with the type-checked and cast object.

        Parameters:
        object - object to be checked
        Returns:
        true if the object matches
      • matchesSafely

        protected abstract boolean matchesSafely​(T object)
        Returns true if the supplied object matches against this matcher.
        Parameters:
        object - object to check for a match
        Returns:
        true on a match