All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.perfectable.introspection.query.MemberQuery Maven / Gradle / Ivy

There is a newer version: 5.1.0
Show newest version
package org.perfectable.introspection.query;

import java.lang.annotation.Annotation;
import java.lang.reflect.AnnotatedElement;
import java.lang.reflect.Member;
import java.lang.reflect.Modifier;
import java.util.regex.Pattern;

/**
 * Extension of {@link AbstractQuery} that matches {@link Member}, that are also {@link AnnotatedElement}.
 *
 * 

Elements of this query have name, modifiers and possible annotations. * *

Double bound was selected to simplify selection, because all relevant members (field, method and constructor) * can be also annotated. * * @param Type of member * @param Type of query that would be produced from restricting results */ abstract class MemberQuery> extends AbstractQuery implements Iterable { /** * Restricts query to members that have specified name, matched exactly. * * @param name name that member must have to match * @return query that filters the same as this query, but returning elements that have specified name */ public abstract Q named(String name); /** * Restricts query to members that have specified name, matched by pattern. * * @param namePattern pattern that member must match to be included in query * @return query that filters the same as this query, but returning elements that have specified name */ public abstract Q nameMatching(Pattern namePattern); /** * Restricts query to members that have an annotation of specified class. * * @param annotationClass class of annotation that member must have to match * @return query that filters the same as this query, but returning elements that have specified annotation */ public Q annotatedWith(Class annotationClass) { return annotatedWith(AnnotationFilter.single(annotationClass)); } /** * Restricts query to members that annotation filter matches. * * @param annotationFilter filter that must match * @return query that filters the same as this query, but returning elements that only match specified filter */ public abstract Q annotatedWith(AnnotationFilter annotationFilter); /** * Restricts query to members that have specified modifier on them. * *

Use {@link Modifier} to select modifiers. * * @param requiredModifier modifier bits that must be present on member * @return query that filters the same as this query, but with modifiers that match provided */ public abstract Q requiringModifier(int requiredModifier); /** * Restricts query to members that do not have specified modifier on them. * *

Use {@link Modifier} to select modifiers. * * @param excludedModifier modifier bits that must not be present on member * @return query that filters the same as this query, but without modifiers that match provided */ public abstract Q excludingModifier(int excludedModifier); /** * Returns query that provides members which have {@link java.lang.reflect.AccessibleObject#setAccessible} * called on them. * * @return query that filters the same as this query, but with accessible flag set */ public abstract Q asAccessible(); }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy