Klasse ReflectionUtil

java.lang.Object
com.github.hypfvieh.util.ReflectionUtil

public final class ReflectionUtil extends Object
Utility methods which uses reflection techniques.
Seit:
v1.0.1 - 2018-02-12
Autor:
David Michaelis (David.Michaelis@baaderbank.de)
  • Methodendetails

    • getAllDeclaredFields

      public static Set<Field> getAllDeclaredFields(Class<?> _class, String... _fieldsToIgnore)
      Extract all Fields found in the given class recursively. This means, all Fields are retrieved, even fields which only exists in superclasses.

      NOTE: Accessibility of Fields returned in the Set have not been changed (setAccessable(true) is NOT called explicitly)!
      Parameter:
      _class - class to analyze
      _fieldsToIgnore - fields to skip
      Gibt zurück:
      null if _class was null, Set otherwise
    • getAllDeclaredStaticFields

      public static Set<Field> getAllDeclaredStaticFields(Class<?> _class, String... _fieldsToIgnore)
      Extract all Fields which are static and do not match any of the given ignore names.
      Parameter:
      _class - class to analyze
      _fieldsToIgnore - fields to skip
      Gibt zurück:
      null if _class was null, Set otherwise
    • getAllDeclaredNonStaticFields

      public static Set<Field> getAllDeclaredNonStaticFields(Class<?> _class, String... _fieldsToIgnore)
      Extract all Fields which are not static and do not match any of the given ignore names.
      Parameter:
      _class - class to analyze
      _fieldsToIgnore - fields to skip
      Gibt zurück:
      null if _class was null, Set otherwise
    • getAllDeclaredFieldsAnnotatedWithAny

      @SafeVarargs public static Set<Field> getAllDeclaredFieldsAnnotatedWithAny(Class<?> _class, Class<? extends Annotation>... _annotations)
      Extract all Fields with any of the given annotations found in the given class recursively. This means, all Fields are retrieved, even fields which only exists in superclasses.

      NOTE: Accessibility of Fields returned in the Set have not been changed (setAccessable(true) is NOT called explicitly)!
      Parameter:
      _class - class to analyze
      _annotations - annotations to check for
      Gibt zurück:
      null if _class was null, Set otherwise
    • getAllDeclaredFieldsNotAnnotatedWithAny

      @SafeVarargs public static Set<Field> getAllDeclaredFieldsNotAnnotatedWithAny(Class<?> _class, Class<? extends Annotation>... _annotations)
      Extract all Fields without any of the given annotations found in the given class recursively. This means, all Fields are retrieved, even fields which only exists in superclasses.

      NOTE: Accessibility of Fields returned in the Set have not been changed (setAccessable(true) is NOT called explicitly)!
      Parameter:
      _class - class to analyze
      _annotations - annotations to check for
      Gibt zurück:
      null if _class was null, Set otherwise
    • getAllDeclaredMethods

      public static Set<Method> getAllDeclaredMethods(Class<?> _class, String... _methodsToIgnore)
      Extract all Methods found in the given class recursively. This means, all Methods are retrieved, even methods which only exists in superclasses.

      NOTE: Accessibility of Methods returned in the Set have not been changed (setAccessable(true) is NOT called explicitly)!
      Parameter:
      _class - class to analyze
      _methodsToIgnore - methods to skip
      Gibt zurück:
      null if _class was null, Set otherwise
      Seit:
      v1.0.2 - 2018-04-20
    • getAllDeclaredStaticMethods

      public static Set<Method> getAllDeclaredStaticMethods(Class<?> _class, String... _methodNamesToIgnore)
      Extract all Methods which are static and do not match any of the given ignore names.
      Parameter:
      _class - class to analyze
      _methodNamesToIgnore - methods to skip
      Gibt zurück:
      null if _class was null, Set otherwise
      Seit:
      v1.0.2 - 2018-04-20
    • getAllDeclaredNonStaticMethods

      public static Set<Method> getAllDeclaredNonStaticMethods(Class<?> _class, String... _methodNamesToIgnore)
      Extract all Methods which are not static and do not match any of the given ignore names.
      Parameter:
      _class - class to analyze
      _methodNamesToIgnore - methods to skip
      Gibt zurück:
      null if _class was null, Set otherwise
      Seit:
      v1.0.2 - 2018-04-20
    • getAllDeclaredMethodsAnnotatedWithAny

      @SafeVarargs public static Set<Method> getAllDeclaredMethodsAnnotatedWithAny(Class<?> _class, Class<? extends Annotation>... _annotations)
      Extract all Methods with any of the given annotations found in the given class recursively. This means, all Methods are retrieved, even fields which only exists in superclasses.

      NOTE: Accessibility of Methods returned in the Set have not been changed (setAccessable(true) is NOT called explicitly)!
      Parameter:
      _class - class to analyze
      _annotations - annotations to check for
      Gibt zurück:
      null if _class was null, Set otherwise
      Seit:
      v1.0.2 - 2018-04-20
    • getAllDeclaredMethodsNotAnnotatedWithAny

      @SafeVarargs public static Set<Method> getAllDeclaredMethodsNotAnnotatedWithAny(Class<?> _class, Class<? extends Annotation>... _annotations)
      Extract all Methods without any of the given annotations found in the given class recursively. This means, all Methods are retrieved, even fields which only exists in superclasses.

      NOTE: Accessibility of Methods returned in the Set have not been changed (setAccessable(true) is NOT called explicitly)!
      Parameter:
      _class - class to analyze
      _annotations - annotations to check for
      Gibt zurück:
      null if _class was null, Set otherwise
      Seit:
      v1.0.2 - 2018-04-20
    • createInstance

      public static <T> T createInstance(Class<T> _clz)
      Tries to create a new instance of the given class type using reflection.

      It is assumed that there is a visible (public) no argument constructor. If instantiation fails, null is returned (exceptions are ignored).

      Typparameter:
      T - type
      Parameter:
      _clz - class to instantiate
      Gibt zurück:
      new instance or null
      Seit:
      v1.2.1 - 2023-01-10