java.lang.Object
io.github.hglabplh_tech.reflect.clojure.api.utils.ClassUtil

public class ClassUtil extends Object
This utility class is for getting the reflection on a specific class which is given by the parameter of the constructor it is for getting the class members via reflective calls
  • Constructor Summary

    Constructors
    Constructor
    Description
    ClassUtil(Class<?> theClass)
    Ctor for this utility class
  • Method Summary

    Modifier and Type
    Method
    Description
    clojure.lang.IPersistentVector
    get all constructors declared in the class even also the constructors being private
    clojure.lang.IPersistentVector
    get all the fields in the class if they are visible and accessible from outside the class or not
    clojure.lang.IPersistentVector
    Get all methods inside the class
    clojure.lang.IPersistentVector
    get all subclasses(inner classes) even if they are visible and accessible from outside or not the class
    Get the class name of the class we defined for work with
    clojure.lang.IPersistentVector
    get the constructors which are visible from outside the class
    clojure.lang.IPersistentVector
     
    If the class or interface represented by this Class object is a member of another class, returns the Class object representing the class in which it was declared.
    If this Class object represents a local or anonymous class within a constructor, returns a Constructor object representing the immediately enclosing constructor of the underlying class.
    If this Class object represents a local or anonymous class within a method, returns a Method object representing the immediately enclosing method of the underlying class.
    clojure.lang.IPersistentVector
    Here the generic Interfaces (something like TypeClass<T> are returned
    this method return a possible generic super-class-type
    clojure.lang.IPersistentVector
    Here the Interfaces are returned
    This method searches a method by its name and gives back an optional Optional <Method> value either empty or the method
    clojure.lang.IPersistentVector
    get the annotations of the class which are visible
    clojure.lang.IPersistentVector
    Get all public fields inside the class
    clojure.lang.IPersistentVector
    get all methods visible as public from outside the class
    clojure.lang.IPersistentVector
    get all subclasses(inner classes) which are visible and accessible from outside the class
    this method return a possible super-class-type (Class )
    getter for the defined class itself
    static clojure.lang.IPersistentMap
     
    static Boolean
    isAssignable(Class<?> interfaceToCheck, Object typeInst)
     
    static boolean
    isClassAnnotation(Class<?> classToCheck)
    returns true if the class given is a annotation otherwise false
    static boolean
    isClassAnonymous(Class<?> classToCheck)
    Returns true if the class is an anonymous class otherwise false
    static boolean
    isClassArray(Class<?> classToCheck)
    Returns true if the class is a Array otherwise false
    static boolean
    isClassEnum(Class<?> classToCheck)
    returns true if the class given is a enum otherwise false
    static boolean
    isClassInterface(Class<?> classToCheck)
    Returns true if the class is a interface otherwise false
    static boolean
    isClassLocal(Class<?> classToCheck)
    Returns true if the class is locel otherwise false
    static boolean
    isClassMember(Class<?> classToCheck)
    Returns true if the class is a member otherwise false
    static boolean
    isClassPrimitive(Class<?> classToCheck)
    Returns true if the class is a primitive otherwise false
    static boolean
    isClassRecord(Class<?> classToCheck)
    Returns true if the class is a record otherwise false
    static boolean
    isClassSealed(Class<?> classToCheck)
    Returns true if the class is sealed
    static boolean
    isClassSynthetic(Class<?> classToCheck)
    returns true if the class given is a synthetic class otherwise false

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ClassUtil

      public ClassUtil(Class<?> theClass)
      Ctor for this utility class
      Parameters:
      theClass - the class we work on
  • Method Details

    • getClassName

      public String getClassName()
      Get the class name of the class we defined for work with
      Returns:
      the canonical class name
    • getTheClass

      public Class<?> getTheClass()
      getter for the defined class itself
      Returns:
      the Class<?> instance
    • getPublicAnnotations

      public clojure.lang.IPersistentVector getPublicAnnotations()
      get the annotations of the class which are visible
      Returns:
      the annotations visible in a Clojure persistance vector
    • getDeclAnnotsByType

      public clojure.lang.IPersistentVector getDeclAnnotsByType(Class<Annotation> annotationClass)
      Parameters:
      annotationClass - the annotation class which defines the type of the annotation we search for e.g. @Test
      Returns:
      the declared annotations with that type
    • getPublicMethods

      public clojure.lang.IPersistentVector getPublicMethods()
      get all methods visible as public from outside the class
      Returns:
      the methods as Clojure persistance vector
    • getConstructors

      public clojure.lang.IPersistentVector getConstructors()
      get the constructors which are visible from outside the class
      Returns:
      the constructor definitions in a Clojure persistance vector
    • getAllConstructors

      public clojure.lang.IPersistentVector getAllConstructors()
      get all constructors declared in the class even also the constructors being private
      Returns:
      the cobstructor definitions as Clojure persistance vector
    • getAllMethods

      public clojure.lang.IPersistentVector getAllMethods()
      Get all methods inside the class
      Returns:
      a Vector with all declared methods either private or public
    • getMethodByName

      public Optional<Method> getMethodByName(String name)
      This method searches a method by its name and gives back an optional Optional <Method> value either empty or the method
      Parameters:
      name - name of the method
      Returns:
      Optional of the method that is searched by name
    • getPublicFields

      public clojure.lang.IPersistentVector getPublicFields()
      Get all public fields inside the class
      Returns:
      a vector with all public fields
    • getAllFields

      public clojure.lang.IPersistentVector getAllFields()
      get all the fields in the class if they are visible and accessible from outside the class or not
      Returns:
      all fields in a Clojure persistance vector
    • getGenericInterfaces

      public clojure.lang.IPersistentVector getGenericInterfaces()
      Here the generic Interfaces (something like TypeClass<T> are returned
      Returns:
      the generic interfaces
    • getInterfaces

      public clojure.lang.IPersistentVector getInterfaces()
      Here the Interfaces are returned
      Returns:
      the generic interfaces
    • getGenericSuperClass

      public Type getGenericSuperClass()
      this method return a possible generic super-class-type
      Returns:
      return the class-type
    • getSuperClass

      public Class<?> getSuperClass()
      this method return a possible super-class-type (Class )
      Returns:
      return the class-type
    • getEnclosingConstructor

      public Constructor<?> getEnclosingConstructor()
      If this Class object represents a local or anonymous class within a constructor, returns a Constructor object representing the immediately enclosing constructor of the underlying class. Returns null otherwise. In particular, this method returns null if the underlying class is a local or anonymous class immediately enclosed by a type declaration, instance initializer or static initializer.
      Returns:
      the enclosing constructor
    • getEnclosingMethod

      public Method getEnclosingMethod()
      If this Class object represents a local or anonymous class within a method, returns a Method object representing the immediately enclosing method of the underlying class. Returns null otherwise. In particular, this method returns null if the underlying class is a local or anonymous class immediately enclosed by a type declaration, instance initializer or static initializer.
      Returns:
      the enclosing method
    • getEnclosingClass

      public Class<?> getEnclosingClass()
      If the class or interface represented by this Class object is a member of another class, returns the Class object representing the class in which it was declared. This method returns null if this class or interface is not a member of any other class. If this Class object represents an array class, a primitive type, or void,then this method returns null.
      Returns:
      the enclosing class
    • getPublicSubClasses

      public clojure.lang.IPersistentVector getPublicSubClasses()
      get all subclasses(inner classes) which are visible and accessible from outside the class
      Returns:
      public sub-classes as Clojure persistent vector
    • getAllSubClasses

      public clojure.lang.IPersistentVector getAllSubClasses()
      get all subclasses(inner classes) even if they are visible and accessible from outside or not the class
      Returns:
    • isAssignable

      public static Boolean isAssignable(Class<?> interfaceToCheck, Object typeInst)
    • getValuesOfInterface

      public static clojure.lang.IPersistentMap getValuesOfInterface(Type typeInst)
    • isClassAnnotation

      public static boolean isClassAnnotation(Class<?> classToCheck)
      returns true if the class given is a annotation otherwise false
      Parameters:
      classToCheck - the class to be checked
      Returns:
      true / false - see description
    • isClassSynthetic

      public static boolean isClassSynthetic(Class<?> classToCheck)
      returns true if the class given is a synthetic class otherwise false
      Parameters:
      classToCheck - the class to be checked
      Returns:
      true / false - see description
    • isClassSealed

      public static boolean isClassSealed(Class<?> classToCheck)
      Returns true if the class is sealed
      Parameters:
      classToCheck - the class which is checked
      Returns:
      true/ false
    • isClassEnum

      public static boolean isClassEnum(Class<?> classToCheck)
      returns true if the class given is a enum otherwise false
      Parameters:
      classToCheck - the class to be checked
      Returns:
      true / false - see description
    • isClassAnonymous

      public static boolean isClassAnonymous(Class<?> classToCheck)
      Returns true if the class is an anonymous class otherwise false
      Parameters:
      classToCheck - the class to be checked
      Returns:
      true / false
    • isClassArray

      public static boolean isClassArray(Class<?> classToCheck)
      Returns true if the class is a Array otherwise false
      Parameters:
      classToCheck - the class to be checked
      Returns:
      true / false
    • isClassMember

      public static boolean isClassMember(Class<?> classToCheck)
      Returns true if the class is a member otherwise false
      Parameters:
      classToCheck - class to be checked
      Returns:
      true / false
    • isClassInterface

      public static boolean isClassInterface(Class<?> classToCheck)
      Returns true if the class is a interface otherwise false
      Parameters:
      classToCheck - the class to be checked
      Returns:
      true / false
    • isClassLocal

      public static boolean isClassLocal(Class<?> classToCheck)
      Returns true if the class is locel otherwise false
      Parameters:
      classToCheck - the class to be checked
      Returns:
      true / false
    • isClassPrimitive

      public static boolean isClassPrimitive(Class<?> classToCheck)
      Returns true if the class is a primitive otherwise false
      Parameters:
      classToCheck - the class to check
      Returns:
      true / false
    • isClassRecord

      public static boolean isClassRecord(Class<?> classToCheck)
      Returns true if the class is a record otherwise false
      Parameters:
      classToCheck - the class to check
      Returns:
      true / false