Class ReflectionUtilsPredicates

  • Direct Known Subclasses:
    ReflectionUtils

    public class ReflectionUtilsPredicates
    extends java.lang.Object
    helper predicates for java meta types
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      private static java.lang.Class<? extends java.lang.annotation.Annotation>[] annotationTypes​(java.lang.annotation.Annotation[] annotations)  
      private static java.util.Set<java.lang.Class<? extends java.lang.annotation.Annotation>> annotationTypes​(java.util.Collection<java.lang.annotation.Annotation> annotations)  
      private static boolean areAnnotationMembersMatching​(java.lang.annotation.Annotation annotation1, java.lang.annotation.Annotation annotation2)  
      static boolean isAssignable​(java.lang.Class[] childClasses, java.lang.Class[] parentClasses)  
      private static java.util.Set<java.lang.annotation.Annotation> parameterAnnotations​(java.lang.reflect.Member member)  
      private static java.lang.Class[] parameterTypes​(java.lang.reflect.Member member)  
      private static java.lang.String toName​(java.lang.Object input)  
      static <T extends java.lang.reflect.AnnotatedElement>
      java.util.function.Predicate<T>
      withAnnotation​(java.lang.annotation.Annotation annotation)
      where element is annotated with given annotation, including member matching
      static <T extends java.lang.reflect.AnnotatedElement>
      java.util.function.Predicate<T>
      withAnnotation​(java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
      where element is annotated with given annotation
      static <T extends java.lang.reflect.AnnotatedElement>
      java.util.function.Predicate<T>
      withAnnotations​(java.lang.annotation.Annotation... annotations)
      where element is annotated with given annotations, including member matching
      static <T extends java.lang.reflect.AnnotatedElement>
      java.util.function.Predicate<T>
      withAnnotations​(java.lang.Class<? extends java.lang.annotation.Annotation>... annotations)
      where element is annotated with given annotations
      static java.util.function.Predicate<java.lang.reflect.Member> withAnyParameterAnnotation​(java.lang.annotation.Annotation annotation)
      when method/constructor has any parameter with an annotation matches given annotations, including member matching
      static java.util.function.Predicate<java.lang.reflect.Member> withAnyParameterAnnotation​(java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass)
      when method/constructor has any parameter with an annotation matches given annotations
      static java.util.function.Predicate<java.lang.Class<?>> withClassModifier​(int mod)
      when class modifier matches given mod
      static <T extends java.lang.reflect.Member>
      java.util.function.Predicate<T>
      withInterface()  
      static <T extends java.lang.reflect.Member>
      java.util.function.Predicate<T>
      withModifier​(int mod)
      when member modifier matches given mod
      static <T extends java.lang.reflect.Member>
      java.util.function.Predicate<T>
      withName​(java.lang.String name)
      where member name equals given name
      static <T> java.util.function.Predicate<T> withNamePrefix​(java.lang.String prefix)
      where annotated element name startsWith given prefix
      static java.util.function.Predicate<java.lang.reflect.Member> withParameters​(java.lang.Class<?>... types)
      when method/constructor parameter types equals given types
      static java.util.function.Predicate<java.lang.reflect.Member> withParametersAssignableFrom​(java.lang.Class... types)
      when method/constructor parameter types assignable from given types
      static java.util.function.Predicate<java.lang.reflect.Member> withParametersAssignableTo​(java.lang.Class... types)
      when member parameter types assignable to given types
      static java.util.function.Predicate<java.lang.reflect.Member> withParametersCount​(int count)
      when method/constructor parameters count equal given count
      static <T extends java.lang.reflect.AnnotatedElement>
      java.util.function.Predicate<T>
      withPattern​(java.lang.String regex)
      where member's toString matches given regex
      static <T extends java.lang.reflect.Member>
      java.util.function.Predicate<T>
      withPrefix​(java.lang.String prefix)
      where member name startsWith given prefix
      static <T extends java.lang.reflect.Member>
      java.util.function.Predicate<T>
      withPublic()
      when member modifier is public
      static <T> java.util.function.Predicate<java.lang.reflect.Method> withReturnType​(java.lang.Class<T> type)
      when method return type equal given type
      static <T> java.util.function.Predicate<java.lang.reflect.Method> withReturnTypeAssignableFrom​(java.lang.Class<T> type)
      when method return type assignable from given type
      static <T extends java.lang.reflect.Member>
      java.util.function.Predicate<T>
      withStatic()  
      static <T> java.util.function.Predicate<java.lang.reflect.Field> withType​(java.lang.Class<T> type)
      when field type equal given type
      static <T> java.util.function.Predicate<java.lang.reflect.Field> withTypeAssignableTo​(java.lang.Class<T> type)
      when field type assignable to given type
      • Methods inherited from class java.lang.Object

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

      • ReflectionUtilsPredicates

        public ReflectionUtilsPredicates()
    • Method Detail

      • withName

        public static <T extends java.lang.reflect.Member> java.util.function.Predicate<T> withName​(java.lang.String name)
        where member name equals given name
      • withPrefix

        public static <T extends java.lang.reflect.Member> java.util.function.Predicate<T> withPrefix​(java.lang.String prefix)
        where member name startsWith given prefix
      • withNamePrefix

        public static <T> java.util.function.Predicate<T> withNamePrefix​(java.lang.String prefix)
        where annotated element name startsWith given prefix
      • withPattern

        public static <T extends java.lang.reflect.AnnotatedElement> java.util.function.Predicate<T> withPattern​(java.lang.String regex)
        where member's toString matches given regex
         get(Methods.of(someClass).filter(withPattern("public void .*"))) 
      • withAnnotation

        public static <T extends java.lang.reflect.AnnotatedElement> java.util.function.Predicate<T> withAnnotation​(java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
        where element is annotated with given annotation
      • withAnnotations

        public static <T extends java.lang.reflect.AnnotatedElement> java.util.function.Predicate<T> withAnnotations​(java.lang.Class<? extends java.lang.annotation.Annotation>... annotations)
        where element is annotated with given annotations
      • withAnnotation

        public static <T extends java.lang.reflect.AnnotatedElement> java.util.function.Predicate<T> withAnnotation​(java.lang.annotation.Annotation annotation)
        where element is annotated with given annotation, including member matching
      • withAnnotations

        public static <T extends java.lang.reflect.AnnotatedElement> java.util.function.Predicate<T> withAnnotations​(java.lang.annotation.Annotation... annotations)
        where element is annotated with given annotations, including member matching
      • withParameters

        public static java.util.function.Predicate<java.lang.reflect.Member> withParameters​(java.lang.Class<?>... types)
        when method/constructor parameter types equals given types
      • withParametersAssignableTo

        public static java.util.function.Predicate<java.lang.reflect.Member> withParametersAssignableTo​(java.lang.Class... types)
        when member parameter types assignable to given types
      • withParametersAssignableFrom

        public static java.util.function.Predicate<java.lang.reflect.Member> withParametersAssignableFrom​(java.lang.Class... types)
        when method/constructor parameter types assignable from given types
      • withParametersCount

        public static java.util.function.Predicate<java.lang.reflect.Member> withParametersCount​(int count)
        when method/constructor parameters count equal given count
      • withAnyParameterAnnotation

        public static java.util.function.Predicate<java.lang.reflect.Member> withAnyParameterAnnotation​(java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass)
        when method/constructor has any parameter with an annotation matches given annotations
      • withAnyParameterAnnotation

        public static java.util.function.Predicate<java.lang.reflect.Member> withAnyParameterAnnotation​(java.lang.annotation.Annotation annotation)
        when method/constructor has any parameter with an annotation matches given annotations, including member matching
      • withType

        public static <T> java.util.function.Predicate<java.lang.reflect.Field> withType​(java.lang.Class<T> type)
        when field type equal given type
      • withTypeAssignableTo

        public static <T> java.util.function.Predicate<java.lang.reflect.Field> withTypeAssignableTo​(java.lang.Class<T> type)
        when field type assignable to given type
      • withReturnType

        public static <T> java.util.function.Predicate<java.lang.reflect.Method> withReturnType​(java.lang.Class<T> type)
        when method return type equal given type
      • withReturnTypeAssignableFrom

        public static <T> java.util.function.Predicate<java.lang.reflect.Method> withReturnTypeAssignableFrom​(java.lang.Class<T> type)
        when method return type assignable from given type
      • withModifier

        public static <T extends java.lang.reflect.Member> java.util.function.Predicate<T> withModifier​(int mod)
        when member modifier matches given mod

        for example:

         withModifier(Modifier.PUBLIC)
         
      • withPublic

        public static <T extends java.lang.reflect.Member> java.util.function.Predicate<T> withPublic()
        when member modifier is public
      • withStatic

        public static <T extends java.lang.reflect.Member> java.util.function.Predicate<T> withStatic()
      • withInterface

        public static <T extends java.lang.reflect.Member> java.util.function.Predicate<T> withInterface()
      • withClassModifier

        public static java.util.function.Predicate<java.lang.Class<?>> withClassModifier​(int mod)
        when class modifier matches given mod

        for example:

         withModifier(Modifier.PUBLIC)
         
      • isAssignable

        public static boolean isAssignable​(java.lang.Class[] childClasses,
                                           java.lang.Class[] parentClasses)
      • toName

        private static java.lang.String toName​(java.lang.Object input)
      • parameterTypes

        private static java.lang.Class[] parameterTypes​(java.lang.reflect.Member member)
      • parameterAnnotations

        private static java.util.Set<java.lang.annotation.Annotation> parameterAnnotations​(java.lang.reflect.Member member)
      • annotationTypes

        private static java.util.Set<java.lang.Class<? extends java.lang.annotation.Annotation>> annotationTypes​(java.util.Collection<java.lang.annotation.Annotation> annotations)
      • annotationTypes

        private static java.lang.Class<? extends java.lang.annotation.Annotation>[] annotationTypes​(java.lang.annotation.Annotation[] annotations)
      • areAnnotationMembersMatching

        private static boolean areAnnotationMembersMatching​(java.lang.annotation.Annotation annotation1,
                                                            java.lang.annotation.Annotation annotation2)