java.lang.Object
ushiosan.jvm.internal.validators.UClassValidator
ushiosan.jvm.internal.validators.UReflectionValidator
ushiosan.jvm.internal.reflection.UReflectionImpl
- Direct Known Subclasses:
UReflectionActions
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final UPair<UFun.UFun1<Boolean,UReflectionOptions<? extends Member>>, Predicate<? extends Member>>[] Pair of elements that are used to filter elements depending on the selected configuration.Fields inherited from class ushiosan.jvm.internal.validators.UClassValidator
INVALID_GET_TYPES, PRIMITIVE_ARRAY_CLASSES, PRIMITIVE_ARRAY_INDIVIDUAL, PRIMITIVE_WRAPPED_CLASSES -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends AccessibleObject>
@NotNull Predicate<T>annotatedWith(boolean inverted, Class<? extends Annotation> @NotNull ... annotations) Generates a filter to check if the object contains one or more annotations.static <T extends AccessibleObject>
@NotNull Predicate<T>annotatedWith(Class<? extends Annotation> @NotNull ... annotations) Generates a filter to check if the object contains one or more annotations.excludeMembers(String @NotNull ... names) Excludes all members matching any of the defined namesExclusive method forFieldtype members.filterFields(@NotNull Class<?> cls, @NotNull UReflectionOptions<Field> options) Filters the fields of a class depending on the filters passed within the configuration passed as a parameter.filterMethods(@NotNull Class<?> cls, @NotNull UReflectionOptions<Method> options) Filters the methods of a class depending on the filters passed within the configuration passed as a parameter.methodReturnType(@NotNull Class<?> type) Exclusive method for members of typeMethod.methodTypeParams(Class<?> @NotNull ... args) Exclusive method for members of typeMethod.modifiers(boolean inverted, int... modifiers) Generates a filter to check if the object contains one or more modifiers.modifiers(int... modifiers) Generates a filter to check if the object contains one or more modifiers.Only valid to members with the name passed as a parameterregexMemberOf(@NotNull String pattern, boolean inverted, int @NotNull ... flags) Generates a filter to capture the elements that meet said restrictionregexMemberOf(@NotNull String pattern, int @NotNull ... flags) Generates a filter to capture the elements that meet said restrictionregexMemberOf(@NotNull Pattern pattern) Generates a filter to capture the elements that meet said restrictionregexMemberOf(@NotNull Pattern pattern, boolean inverted) Generates a filter to capture the elements that meet said restrictionValidates that a member is valid to get its value.Methods inherited from class ushiosan.jvm.internal.validators.UReflectionValidator
checkRecursiveCall
-
Field Details
-
MEMBER_FILTER_ARRAY
protected static final UPair<UFun.UFun1<Boolean,UReflectionOptions<? extends Member>>, MEMBER_FILTER_ARRAYPredicate<? extends Member>>[] Pair of elements that are used to filter elements depending on the selected configuration.
-
-
Constructor Details
-
UReflectionImpl
public UReflectionImpl()
-
-
Method Details
-
filterMethods
public static Method @NotNull [] filterMethods(@NotNull @NotNull Class<?> cls, @NotNull @NotNull UReflectionOptions<Method> options) Filters the methods of a class depending on the filters passed within the configuration passed as a parameter.- Parameters:
cls- the class where you want to search for class membersoptions- search options- Returns:
- the methods found based on the filters passed.
-
filterFields
public static Field @NotNull [] filterFields(@NotNull @NotNull Class<?> cls, @NotNull @NotNull UReflectionOptions<Field> options) Filters the fields of a class depending on the filters passed within the configuration passed as a parameter.- Parameters:
cls- the class where you want to search for class membersoptions- search options- Returns:
- the fields found based on the filters passed.
-
regexMemberOf
@NotNull public static <T extends Member> @NotNull Predicate<T> regexMemberOf(@NotNull @RegExp @NotNull String pattern, boolean inverted, @MagicConstant(flagsFromClass=java.util.regex.Pattern.class) int @NotNull ... flags) Generates a filter to capture the elements that meet said restriction- Type Parameters:
T- generic member type- Parameters:
pattern- regular expression to applyinverted- option to perform the action invertedflags- regular expression configuration flags- Returns:
- the filter instance with the desired behavior
- See Also:
-
regexMemberOf
@NotNull public static <T extends Member> @NotNull Predicate<T> regexMemberOf(@NotNull @RegExp @NotNull String pattern, @MagicConstant(flagsFromClass=java.util.regex.Pattern.class) int @NotNull ... flags) Generates a filter to capture the elements that meet said restriction- Type Parameters:
T- generic member type- Parameters:
pattern- regular expression to applyflags- regular expression configuration flags- Returns:
- the filter instance with the desired behavior
- See Also:
-
regexMemberOf
@NotNull public static <T extends Member> @NotNull Predicate<T> regexMemberOf(@NotNull @NotNull Pattern pattern, boolean inverted) Generates a filter to capture the elements that meet said restriction- Type Parameters:
T- generic member type- Parameters:
pattern- regular expression to applyinverted- option to perform the action inverted- Returns:
- the filter instance with the desired behavior
- See Also:
-
regexMemberOf
@NotNull public static <T extends Member> @NotNull Predicate<T> regexMemberOf(@NotNull @NotNull Pattern pattern) Generates a filter to capture the elements that meet said restriction- Type Parameters:
T- generic member type- Parameters:
pattern- regular expression to apply- Returns:
- the filter instance with the desired behavior
- See Also:
-
named
@NotNull public static <T extends Member> @NotNull Predicate<T> named(@NotNull @NotNull String name) Only valid to members with the name passed as a parameter- Type Parameters:
T- generic member type- Parameters:
name- the name of the member you want to search for- Returns:
- the filter instance with the desired behavior
-
excludeMembers
@NotNull public static <T extends Member> @NotNull Predicate<T> excludeMembers(String @NotNull ... names) Excludes all members matching any of the defined names- Type Parameters:
T- generic member type- Parameters:
names- the names you want to exclude- Returns:
- the filter instance with the desired behavior
-
validObtainMember
Validates that a member is valid to get its value. In the case of class fields, it is verified that their type is not "void" and in the case of methods, it only applies to getter methods and those that do not return "void" values.- Type Parameters:
T- generic member type- Returns:
- the filter instance with the desired behavior
-
fieldType
Exclusive method forFieldtype members. Used to verify that an element is of the set type.- Parameters:
type- the type you want to parse- Returns:
- the filter instance with the desired behavior
-
methodTypeParams
Exclusive method for members of typeMethod. It is used to verify that an element requires the passed parameters.- Parameters:
args- array of arguments required by the searched method- Returns:
- the filter instance with the desired behavior
-
methodReturnType
Exclusive method for members of typeMethod. It is used to verify that the method returns the desired result.- Parameters:
type- data type required for method return- Returns:
- the filter instance with the desired behavior
-
annotatedWith
@SafeVarargs @NotNull public static <T extends AccessibleObject> @NotNull Predicate<T> annotatedWith(boolean inverted, Class<? extends Annotation> @NotNull ... annotations) Generates a filter to check if the object contains one or more annotations.- Type Parameters:
T- generic accessible type- Parameters:
inverted- option to perform the action invertedannotations- the annotations that are required- Returns:
- the filter instance with the desired behavior
-
annotatedWith
@SafeVarargs @NotNull public static <T extends AccessibleObject> @NotNull Predicate<T> annotatedWith(Class<? extends Annotation> @NotNull ... annotations) Generates a filter to check if the object contains one or more annotations.- Type Parameters:
T- generic accessible type- Parameters:
annotations- the annotations that are required- Returns:
- the filter instance with the desired behavior
-
modifiers
@NotNull public static <T extends Member> @NotNull Predicate<T> modifiers(boolean inverted, @MagicConstant(valuesFromClass=java.lang.reflect.Modifier.class) int... modifiers) Generates a filter to check if the object contains one or more modifiers. Modifiers can be individual or plural, where they all have to be true for the filter to be valid.- Type Parameters:
T- generic accessible type- Parameters:
inverted- option for the condition to be inverse to the one establishedmodifiers- array with all access modifiers- Returns:
- the filter instance with the desired behavior
- See Also:
-
modifiers
@NotNull public static <T extends Member> @NotNull Predicate<T> modifiers(@MagicConstant(valuesFromClass=java.lang.reflect.Modifier.class) int... modifiers) Generates a filter to check if the object contains one or more modifiers. Modifiers can be individual or plural, where they all have to be true for the filter to be valid.- Type Parameters:
T- generic accessible type- Parameters:
modifiers- array with all access modifiers- Returns:
- the filter instance with the desired behavior
- See Also:
-