Class ClassUtil
java.lang.Object
io.github.hglabplh_tech.reflect.clojure.api.utils.ClassUtil
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 -
Method Summary
Modifier and TypeMethodDescriptionclojure.lang.IPersistentVectorget all constructors declared in the class even also the constructors being privateclojure.lang.IPersistentVectorget all the fields in the class if they are visible and accessible from outside the class or notclojure.lang.IPersistentVectorGet all methods inside the classclojure.lang.IPersistentVectorget all subclasses(inner classes) even if they are visible and accessible from outside or not the classGet the class name of the class we defined for work withclojure.lang.IPersistentVectorget the constructors which are visible from outside the classclojure.lang.IPersistentVectorgetDeclAnnotsByType(Class<Annotation> annotationClass) Class<?>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.Constructor<?>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.IPersistentVectorHere the generic Interfaces (something like TypeClass<T> are returnedthis method return a possible generic super-class-typeclojure.lang.IPersistentVectorHere the Interfaces are returnedgetMethodByName(String name) This method searches a method by its name and gives back an optionalOptional <Method>value either empty or the methodclojure.lang.IPersistentVectorget the annotations of the class which are visibleclojure.lang.IPersistentVectorGet all public fields inside the classclojure.lang.IPersistentVectorget all methods visible as public from outside the classclojure.lang.IPersistentVectorget all subclasses(inner classes) which are visible and accessible from outside the classClass<?>this method return a possible super-class-type (Class )Class<?>getter for the defined class itselfstatic clojure.lang.IPersistentMapgetValuesOfInterface(Type typeInst) static BooleanisAssignable(Class<?> interfaceToCheck, Object typeInst) static booleanisClassAnnotation(Class<?> classToCheck) returns true if the class given is a annotation otherwise falsestatic booleanisClassAnonymous(Class<?> classToCheck) Returns true if the class is an anonymous class otherwise falsestatic booleanisClassArray(Class<?> classToCheck) Returns true if the class is a Array otherwise falsestatic booleanisClassEnum(Class<?> classToCheck) returns true if the class given is a enum otherwise falsestatic booleanisClassInterface(Class<?> classToCheck) Returns true if the class is a interface otherwise falsestatic booleanisClassLocal(Class<?> classToCheck) Returns true if the class is locel otherwise falsestatic booleanisClassMember(Class<?> classToCheck) Returns true if the class is a member otherwise falsestatic booleanisClassPrimitive(Class<?> classToCheck) Returns true if the class is a primitive otherwise falsestatic booleanisClassRecord(Class<?> classToCheck) Returns true if the class is a record otherwise falsestatic booleanisClassSealed(Class<?> classToCheck) Returns true if the class is sealedstatic booleanisClassSynthetic(Class<?> classToCheck) returns true if the class given is a synthetic class otherwise false
-
Constructor Details
-
ClassUtil
Ctor for this utility class- Parameters:
theClass- the class we work on
-
-
Method Details
-
getClassName
Get the class name of the class we defined for work with- Returns:
- the canonical class name
-
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
- 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
This method searches a method by its name and gives back an optionalOptional <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
this method return a possible generic super-class-type- Returns:
- return the class-type
-
getSuperClass
this method return a possible super-class-type (Class )- Returns:
- return the class-type
-
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
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
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
-
getValuesOfInterface
-
isClassAnnotation
returns true if the class given is a annotation otherwise false- Parameters:
classToCheck- the class to be checked- Returns:
- true / false - see description
-
isClassSynthetic
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
Returns true if the class is sealed- Parameters:
classToCheck- the class which is checked- Returns:
- true/ false
-
isClassEnum
returns true if the class given is a enum otherwise false- Parameters:
classToCheck- the class to be checked- Returns:
- true / false - see description
-
isClassAnonymous
Returns true if the class is an anonymous class otherwise false- Parameters:
classToCheck- the class to be checked- Returns:
- true / false
-
isClassArray
Returns true if the class is a Array otherwise false- Parameters:
classToCheck- the class to be checked- Returns:
- true / false
-
isClassMember
Returns true if the class is a member otherwise false- Parameters:
classToCheck- class to be checked- Returns:
- true / false
-
isClassInterface
Returns true if the class is a interface otherwise false- Parameters:
classToCheck- the class to be checked- Returns:
- true / false
-
isClassLocal
Returns true if the class is locel otherwise false- Parameters:
classToCheck- the class to be checked- Returns:
- true / false
-
isClassPrimitive
Returns true if the class is a primitive otherwise false- Parameters:
classToCheck- the class to check- Returns:
- true / false
-
isClassRecord
Returns true if the class is a record otherwise false- Parameters:
classToCheck- the class to check- Returns:
- true / false
-