Reflected
- The class to be reflected.public class ClassMirror<Reflected> extends Object
Constructor and Description |
---|
ClassMirror(Class<? extends Reflected> reflectedClass)
Public constructor for the reflection class.
|
ClassMirror(Integer depth)
Public constructor for the reflection class.
|
ClassMirror(String reflectedClassName)
Public constructor for the reflection class.
|
ClassMirror(String reflectedClassName,
ClassLoader classLoader,
Boolean initialize)
Public constructor for the reflection class.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object obj) |
<AnyAnnotation extends Annotation> |
getAnnotation(Class<AnyAnnotation> annotationClass)
Returns an annotation from the reflected class (or its inherited classes and interfaces).
|
Set<AnnotationMirror<?>> |
getAnnotations()
Gets all annotations from a class.
|
<AnyAnnotation extends Annotation> |
getAnnotations(Class<AnyAnnotation> annotationClass)
Gets all annotations with a given type.
|
MethodMirror |
getAnyMethod(String methodName,
Class<?>[] paramsClasses)
Gets any method (despite of its modifiers) in the current class.
|
static Class<?> |
getClass(String className,
ClassLoader classLoader,
Boolean initialize)
Gets a class with the given name from a given class loader.
|
ConstructorMirror<Reflected> |
getConstructor(Class<?>[] paramsClasses)
Gets a constructor from the reflected class for the given parameters.
|
ConstructorMirror<Reflected> |
getConstructor(Object[] paramsValues)
Gets a constructor from the reflected class for the given parameters.
|
static Class<?> |
getCurrentClass(Integer depth)
Gets the current class (with the selected depth) being executed.
|
static String |
getCurrentClassName(Integer depth)
Gets the name of the current class (with the selected depth) being executed.
|
FieldMirror |
getField(String fieldName)
Returns a field from the reflected class.
|
FieldPath |
getFieldPath(String fieldNamePath)
Gets a field path for the reflected class.
|
Collection<FieldMirror> |
getFields()
Returns all fields (public or not) from the reflected class (including inherited ones).
|
Collection<FieldMirror> |
getFields(Class<? extends Annotation> annotation)
Returns the fields annotated with the given annotation.
|
MethodMirror |
getMethod(String methodName,
Class<?>[] paramsClasses)
Gets a method from the reflected class for the given parameters.
|
MethodMirror |
getMethod(String methodName,
Object[] paramsValues)
Gets a method from the reflected class for the given parameters.
|
String |
getPackageAsDirPath()
Gets the class package as a directory path.
|
Class<? extends Reflected> |
getReflectedClass()
Gets the class being reflected.
|
Set<ClassMirror<?>> |
getSuperClasses(Boolean includeInterfaces)
Gets all the classes and interfaces inherited by the reflected class (including this one).
|
int |
hashCode() |
protected void |
setReflectedClass(Class<? extends Reflected> reflectedClass)
Sets the class being reflected.
|
public ClassMirror(Class<? extends Reflected> reflectedClass) throws org.dejava.component.exception.localized.unchecked.EmptyParameterException
reflectedClass
- Class being reflected.org.dejava.component.exception.localized.unchecked.EmptyParameterException
- If the reflected class is not given.public ClassMirror(String reflectedClassName, ClassLoader classLoader, Boolean initialize) throws org.dejava.component.exception.localized.unchecked.InvalidParameterException
reflectedClassName
- Full qualified name of the class being reflected.classLoader
- Class loader to be used with the reflected class. If no class loader is given, the context
class loader is used.initialize
- Whether the class must be initialized. Default is true.org.dejava.component.exception.localized.unchecked.InvalidParameterException
- If the class cannot be found for the name.public ClassMirror(String reflectedClassName) throws org.dejava.component.exception.localized.unchecked.InvalidParameterException
reflectedClassName
- Full qualified name of the class being reflected.org.dejava.component.exception.localized.unchecked.InvalidParameterException
- If the class cannot be found for the name.public ClassMirror(Integer depth) throws org.dejava.component.exception.localized.unchecked.InvalidParameterException
depth
- Depth in the current stack for the desired class (0 is the first and so on).org.dejava.component.exception.localized.unchecked.InvalidParameterException
- If the class cannot be found for the name or if the depth is greater than the stack trace
size.public Class<? extends Reflected> getReflectedClass()
protected void setReflectedClass(Class<? extends Reflected> reflectedClass)
reflectedClass
- New class being reflected.public static Class<?> getClass(String className, ClassLoader classLoader, Boolean initialize) throws org.dejava.component.exception.localized.unchecked.InvalidParameterException, org.dejava.component.exception.localized.unchecked.EmptyParameterException
className
- Name of the class to be found.classLoader
- Class loader to load the class. If no class loader is given, the context class loader is
used.initialize
- Whether the class must be initialized.org.dejava.component.exception.localized.unchecked.EmptyParameterException
- If the class name is not given.org.dejava.component.exception.localized.unchecked.InvalidParameterException
- If the class cannot be found for the name.public static String getCurrentClassName(Integer depth) throws org.dejava.component.exception.localized.unchecked.InvalidParameterException
depth
- Depth in the current stack for the desired class (0 is the first and so on).org.dejava.component.exception.localized.unchecked.InvalidParameterException
- If the depth is greater than the stack trace size.public static Class<?> getCurrentClass(Integer depth) throws org.dejava.component.exception.localized.unchecked.InvalidParameterException
depth
- Depth in the current stack for the desired class (0 is the first and so on).org.dejava.component.exception.localized.unchecked.InvalidParameterException
- If the class cannot be found for the name or if the depth is greater than the stack trace
size.public Set<ClassMirror<?>> getSuperClasses(Boolean includeInterfaces)
includeInterfaces
- If the interfaces of the class should be included.public Collection<FieldMirror> getFields()
public Collection<FieldMirror> getFields(Class<? extends Annotation> annotation)
annotation
- The annotations that the fields should be annotated with.public FieldMirror getField(String fieldName) throws org.dejava.component.exception.localized.unchecked.InvalidParameterException, org.dejava.component.exception.localized.unchecked.EmptyParameterException
fieldName
- Name of the field to be found.org.dejava.component.exception.localized.unchecked.EmptyParameterException
- If the name is not given.org.dejava.component.exception.localized.unchecked.InvalidParameterException
- If the field cannot be found for the name.public FieldPath getFieldPath(String fieldNamePath)
fieldNamePath
- Field path using the desired field names. Using the format: "field1.field2.*.*".public String getPackageAsDirPath()
public MethodMirror getAnyMethod(String methodName, Class<?>[] paramsClasses)
methodName
- Name of the method to be found.paramsClasses
- The exact parameters classes for the method to be found.public MethodMirror getMethod(String methodName, Class<?>[] paramsClasses) throws org.dejava.component.exception.localized.unchecked.InvalidParameterException, org.dejava.component.exception.localized.unchecked.EmptyParameterException
methodName
- Name of the method to be found.paramsClasses
- Parameters classes for the method to be found.org.dejava.component.exception.localized.unchecked.EmptyParameterException
- If the method name is empty.org.dejava.component.exception.localized.unchecked.InvalidParameterException
- If the method cannot be found or one of the parameters classes is empty.public MethodMirror getMethod(String methodName, Object[] paramsValues) throws org.dejava.component.exception.localized.unchecked.InvalidParameterException, org.dejava.component.exception.localized.unchecked.EmptyParameterException
methodName
- Name of the method to be found.paramsValues
- Parameters values to be used during the method invocation.org.dejava.component.exception.localized.unchecked.EmptyParameterException
- If the method name is empty.org.dejava.component.exception.localized.unchecked.InvalidParameterException
- If the method cannot be found or one of the parameters values is empty.public Set<AnnotationMirror<?>> getAnnotations()
public <AnyAnnotation extends Annotation> Collection<AnnotationMirror<AnyAnnotation>> getAnnotations(Class<AnyAnnotation> annotationClass)
AnyAnnotation
- Any annotation being searched.annotationClass
- Type of the annotation to be searched for.public <AnyAnnotation extends Annotation> AnnotationMirror<AnyAnnotation> getAnnotation(Class<AnyAnnotation> annotationClass) throws org.dejava.component.exception.localized.unchecked.EmptyParameterException
AnyAnnotation
- Any annotation being searched.annotationClass
- Type of the annotation to be searched for.org.dejava.component.exception.localized.unchecked.EmptyParameterException
- If the passed class is null.public ConstructorMirror<Reflected> getConstructor(Class<?>[] paramsClasses) throws org.dejava.component.exception.localized.unchecked.InvalidParameterException
paramsClasses
- Parameters classes for the constructor to be found.org.dejava.component.exception.localized.unchecked.InvalidParameterException
- If the constructor cannot be found or one of the parameters classes is empty.public ConstructorMirror<Reflected> getConstructor(Object[] paramsValues) throws org.dejava.component.exception.localized.unchecked.InvalidParameterException
paramsValues
- Parameters values to be used during the constructor invocation.org.dejava.component.exception.localized.unchecked.InvalidParameterException
- If the constructor cannot be found or one of the parameters values is empty.public int hashCode()
hashCode
in class Object
Object.hashCode()
public boolean equals(Object obj)
equals
in class Object
Object.equals(java.lang.Object)
Copyright © 2013. All Rights Reserved.