Class BaseMatcher<T extends Member, M extends BaseMatcher<T,M>>
java.lang.Object
dev.derklaro.reflexion.matcher.BaseMatcher<T,M>
- Type Parameters:
T- the type of the class member matched by this matcher.M- the type of the matcher itself.
- All Implemented Interfaces:
Predicate<T>
- Direct Known Subclasses:
ConstructorMatcher,FieldMatcher,MethodMatcher
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionComposes the current matching predicate with the supplied one using an AND operation.denyModifier(int mod) Checks if the given member doesn't have the given modifier.denyModifiers(int... mods) Checks if the given member doesn't have all the given modifiers.derivedType(@NotNull Function<T, Class<?>> typeReader, @NotNull Class<?> expectedType) Checks if the supplied type from the reader function is a derived instance of the given type (input instanceof expected).derivedTypeAt(@NotNull Function<T, Class<?>[]> reader, @NotNull Class<?> expectedType, int idx) Checks if the type array extracted from the target member has the given type at the given index (input instanceof expected).derivedTypes(@NotNull Function<T, Class<?>[]> reader, @NotNull Class<?>... expectedTypes) Checks if all types supplied by the given type reader match the given types.Checks if the supplied type from the reader function is exactly the given expected type.exactTypeAt(@NotNull Function<T, Class<?>[]> typesReader, @NotNull Class<?> expectedType, int idx) Checks if the type array extracted from the target member has the given type at the given index.exactTypes(@NotNull Function<T, Class<?>[]> typesReader, @NotNull Class<?>... expectedTypes) Checks if all types supplied by the given type reader match the given types.hasMatchingName(@NotNull String name, int... flags) Checks if the member has a name which matches the given regexp.hasModifier(int mod) Checks if the member has the given modifier.hasModifiers(int... mods) Checks if the member has all the given modifiers.Checks if the member has the exact name which was supplied.negate()Negates the current matching predicate.Composes the current matching predicate with the supplied one using an OR operation.Checks if the supplied type from the reader function is an instance of the expected type (expected instanceof input).superTypeAt(@NotNull Function<T, Class<?>[]> typesReader, @NotNull Class<?> expectedType, int idx) Checks if the type array extracted from the target member has the given type at the given index (expected instanceof input).superTypes(@NotNull Function<T, Class<?>[]> typesReader, @NotNull Class<?>... expectedTypes) Checks if all types supplied by the given type reader match the given types.boolean
-
Field Details
-
currentMatcher
-
-
Constructor Details
-
BaseMatcher
public BaseMatcher()
-
-
Method Details
-
hasName
Checks if the member has the exact name which was supplied.- Parameters:
name- the name the member must have.- Returns:
- the same instance as used to call the method, for chaining.
- Throws:
NullPointerException- if the given name is null.
-
hasMatchingName
@NotNull public M hasMatchingName(@NotNull @Language("RegExp") @NotNull String name, @MagicConstant(flagsFromClass=Pattern.class) int... flags) Checks if the member has a name which matches the given regexp.- Parameters:
name- the regexp for the member name.flags- the match flags to supply to the pattern.- Returns:
- the same instance as used to call the method, for chaining.
- Throws:
NullPointerException- if the given name is null.IllegalArgumentException- if illegal match flags were supplied.PatternSyntaxException- if the given regexp is invalid.
-
hasModifier
Checks if the member has the given modifier.- Parameters:
mod- the modifier which the member should have.- Returns:
- the same instance as used to call the method, for chaining.
-
hasModifiers
Checks if the member has all the given modifiers.- Parameters:
mods- the modifiers which the member should have.- Returns:
- the same instance as used to call the method, for chaining.
-
denyModifier
Checks if the given member doesn't have the given modifier.- Parameters:
mod- the modifier which the given member shouldn't have.- Returns:
- the same instance as used to call the method, for chaining.
-
denyModifiers
Checks if the given member doesn't have all the given modifiers.- Parameters:
mods- the modifiers which the member shouldn't have.- Returns:
- the same instance as used to call the method, for chaining.
-
exactType
@NotNull public M exactType(@NotNull @NotNull Function<T, Class<?>> typeReader, @NotNull @NotNull Class<?> expectedType) Checks if the supplied type from the reader function is exactly the given expected type.- Parameters:
typeReader- the type extractor from the target member.expectedType- the type which is expected.- Returns:
- the same instance as used to call the method, for chaining.
- Throws:
NullPointerException- if the given reader function or expected type is null.
-
superType
@NotNull public M superType(@NotNull @NotNull Function<T, Class<?>> typeReader, @NotNull @NotNull Class<?> expectedType) Checks if the supplied type from the reader function is an instance of the expected type (expected instanceof input).- Parameters:
typeReader- the type extractor from the target member.expectedType- the type which is being matched.- Returns:
- the same instance as used to call the method, for chaining.
- Throws:
NullPointerException- if the given reader function or expected type is null.
-
derivedType
@NotNull public M derivedType(@NotNull @NotNull Function<T, Class<?>> typeReader, @NotNull @NotNull Class<?> expectedType) Checks if the supplied type from the reader function is a derived instance of the given type (input instanceof expected).- Parameters:
typeReader- the type extractor from the target member.expectedType- the type which is being matched.- Returns:
- the same instance as used to call the method, for chaining.
- Throws:
NullPointerException- if the given type extractor or expected type is null.
-
exactTypes
@NotNull public M exactTypes(@NotNull @NotNull Function<T, Class<?>[]> typesReader, @NotNull @NotNull Class<?>... expectedTypes) Checks if all types supplied by the given type reader match the given types.- Parameters:
typesReader- the extractor of the types from the target member.expectedTypes- the types which are expected.- Returns:
- the same instance as used to call the method, for chaining.
- Throws:
NullPointerException- if the given extractor or expected type array is null.
-
superTypes
@NotNull public M superTypes(@NotNull @NotNull Function<T, Class<?>[]> typesReader, @NotNull @NotNull Class<?>... expectedTypes) Checks if all types supplied by the given type reader match the given types. (expected instanceof input).- Parameters:
typesReader- the extractor of the types from the target member.expectedTypes- the types which are expected.- Returns:
- the same instance as used to call the method, for chaining.
- Throws:
NullPointerException- if the given extractor or expected type array is null.
-
derivedTypes
@NotNull public M derivedTypes(@NotNull @NotNull Function<T, Class<?>[]> reader, @NotNull @NotNull Class<?>... expectedTypes) Checks if all types supplied by the given type reader match the given types. (input instanceof expected).- Parameters:
reader- the extractor of the types from the target member.expectedTypes- the types which are expected.- Returns:
- the same instance as used to call the method, for chaining.
- Throws:
NullPointerException- if the given extractor or expected type array is null.
-
exactTypeAt
@NotNull public M exactTypeAt(@NotNull @NotNull Function<T, Class<?>[]> typesReader, @NotNull @NotNull Class<?> expectedType, int idx) Checks if the type array extracted from the target member has the given type at the given index. This matcher will also not match if the given index either underflow the array length (< 0) or overflows the array length.- Parameters:
typesReader- the extractor of the types from the target member.expectedType- the type which is expected at the given position.idx- the position to check the type of.- Returns:
- the same instance as used to call the method, for chaining.
- Throws:
NullPointerException- if the given type reader or expected type is null.
-
superTypeAt
@NotNull public M superTypeAt(@NotNull @NotNull Function<T, Class<?>[]> typesReader, @NotNull @NotNull Class<?> expectedType, int idx) Checks if the type array extracted from the target member has the given type at the given index (expected instanceof input). This matcher will also not match if the given index either underflow the array length (< 0) or overflows the array length.- Parameters:
typesReader- the extractor of the types from the target member.expectedType- the type which is expected at the given position.idx- the position to check the type of.- Returns:
- the same instance as used to call the method, for chaining.
- Throws:
NullPointerException- if the given type reader or expected type is null.
-
derivedTypeAt
@NotNull public M derivedTypeAt(@NotNull @NotNull Function<T, Class<?>[]> reader, @NotNull @NotNull Class<?> expectedType, int idx) Checks if the type array extracted from the target member has the given type at the given index (input instanceof expected). This matcher will also not match if the given index either underflow the array length (< 0) or overflows the array length.- Parameters:
reader- the extractor of the types from the target member.expectedType- the type which is expected at the given position.idx- the position to check the type of.- Returns:
- the same instance as used to call the method, for chaining.
- Throws:
NullPointerException- if the given type reader or expected type is null.
-
test
-
and
Composes the current matching predicate with the supplied one using an AND operation. Note: other than the super method this method mutates this object rather than returning a new matcher object.- Specified by:
andin interfacePredicate<T extends Member>- Parameters:
other- the other predicate which must match.- Returns:
- the same instance as used to call the method, for chaining.
- Throws:
NullPointerException- if the other predicate is null.
-
or
Composes the current matching predicate with the supplied one using an OR operation. Note: other than the super method this method mutates this object rather than returning a new matcher object.- Specified by:
orin interfacePredicate<T extends Member>- Parameters:
other- the other predicate which must match.- Returns:
- the same instance as used to call the method, for chaining.
- Throws:
NullPointerException- if the other predicate is null.
-
negate
Negates the current matching predicate. Note: other than the super method this method mutates this object rather than returning a new matcher object.
-