java.lang.Object
ushiosan.jvm_utilities.lang.reflection.FieldUtils

public final class FieldUtils extends Object
  • Method Summary

    Modifier and Type
    Method
    Description
    static 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 Field
    findField(@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 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 Field
    findFieldObj(@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.
    static Field @NotNull []
    Returns all defined and undefined fields of a class (for this, this method accesses the inheritance tree to get all these fields)
    static Field @NotNull []
    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)

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 inspect
      field - the field you want to search for
      recursive - returns inputs recursively
      onlyPublic - returns only public entries
      skipAbstracts - 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 inspect
      field - 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 inspect
      field - the field you want to search for
      recursive - returns inputs recursively
      onlyPublic - returns only public entries
      skipAbstracts - 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 inspect
      field - 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 inspect
      recursive - returns inputs recursively
      onlyPublic - returns only public entries
      skipAbstracts - omit all abstract entries
      Returns:
      all valid class fields
    • getAllClassFields

      public static Field @NotNull [] getAllClassFields(@NotNull @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)
      Parameters:
      cls - the class you want to inspect
      Returns:
      all valid class fields