Class FieldUtils
java.lang.Object
ushiosan.jvm_utilities.lang.reflection.FieldUtils
-
Method Summary
Modifier and TypeMethodDescriptionstatic FieldIt searches inside a class (also inside the classes it inherits) and identifies the one that is mentioned inside the parameters of the method.static FieldfindField(@NotNull Class<?> cls, @NotNull String field, boolean recursive, boolean onlyPublic, boolean skipAbstracts) It searches inside a class (also inside the classes it inherits) and identifies the one that is mentioned inside the parameters of the method.static FieldfindFieldObj(@NotNull Object obj, @NotNull String field) It searches inside a class (also inside the classes it inherits) and identifies the one that is mentioned inside the parameters of the method.static FieldfindFieldObj(@NotNull Object obj, @NotNull String field, boolean recursive, boolean onlyPublic, boolean skipAbstracts) It searches inside a class (also inside the classes it inherits) and identifies the one that is mentioned inside the parameters of the method.getAllClassFields(@NotNull Class<?> cls) Returns all defined and undefined fields of a class (for this, this method accesses the inheritance tree to get all these fields)getAllClassFields(@NotNull Class<?> cls, boolean recursive, boolean onlyPublic, boolean skipAbstracts) Returns all defined and undefined fields of a class (for this, this method accesses the inheritance tree to get all these fields)
-
Method Details
-
findField
public static Field findField(@NotNull @NotNull Class<?> cls, @NotNull @NotNull String field, boolean recursive, boolean onlyPublic, boolean skipAbstracts) throws NoSuchFieldException It searches inside a class (also inside the classes it inherits) and identifies the one that is mentioned inside the parameters of the method. Java handles fields independently for each class, and you cannot access a field that is inside another class, but inherits from it. That is why a trick is performed to perform such a task.- Parameters:
cls- the class you want to inspectfield- the field you want to search forrecursive- returns inputs recursivelyonlyPublic- returns only public entriesskipAbstracts- omit all abstract entries- Returns:
- the class field you want to access
- Throws:
NoSuchFieldException- Error if such field does not exist in the entire inheritance tree of the class
-
findField
public static Field findField(@NotNull @NotNull Class<?> cls, @NotNull @NotNull String field) throws NoSuchFieldException It searches inside a class (also inside the classes it inherits) and identifies the one that is mentioned inside the parameters of the method. Java handles fields independently for each class, and you cannot access a field that is inside another class, but inherits from it. That is why a trick is performed to perform such a task.- Parameters:
cls- the class you want to inspectfield- the field you want to search for- Returns:
- the class field you want to access
- Throws:
NoSuchFieldException- Error if such field does not exist in the entire inheritance tree of the class
-
findFieldObj
public static Field findFieldObj(@NotNull @NotNull Object obj, @NotNull @NotNull String field, boolean recursive, boolean onlyPublic, boolean skipAbstracts) throws NoSuchFieldException It searches inside a class (also inside the classes it inherits) and identifies the one that is mentioned inside the parameters of the method. Java handles fields independently for each class, and you cannot access a field that is inside another class, but inherits from it. That is why a trick is performed to perform such a task.- Parameters:
obj- the object you want to inspectfield- the field you want to search forrecursive- returns inputs recursivelyonlyPublic- returns only public entriesskipAbstracts- omit all abstract entries- Returns:
- the class field you want to access
- Throws:
NoSuchFieldException- Error if such field does not exist in the entire inheritance tree of the class
-
findFieldObj
public static Field findFieldObj(@NotNull @NotNull Object obj, @NotNull @NotNull String field) throws NoSuchFieldException It searches inside a class (also inside the classes it inherits) and identifies the one that is mentioned inside the parameters of the method. Java handles fields independently for each class, and you cannot access a field that is inside another class, but inherits from it. That is why a trick is performed to perform such a task.- Parameters:
obj- the object you want to inspectfield- the field you want to search for- Returns:
- the class field you want to access
- Throws:
NoSuchFieldException- Error if such field does not exist in the entire inheritance tree of the class
-
getAllClassFields
public static Field @NotNull [] getAllClassFields(@NotNull @NotNull Class<?> cls, boolean recursive, boolean onlyPublic, boolean skipAbstracts) Returns all defined and undefined fields of a class (for this, this method accesses the inheritance tree to get all these fields)- Parameters:
cls- the class you want to inspectrecursive- returns inputs recursivelyonlyPublic- returns only public entriesskipAbstracts- omit all abstract entries- Returns:
- all valid class fields
-
getAllClassFields
Returns all defined and undefined fields of a class (for this, this method accesses the inheritance tree to get all these fields)- Parameters:
cls- the class you want to inspect- Returns:
- all valid class fields
-