Class ReflectionUtils
This class provides static factory methods that convert standard Java reflection objects
(Class, Method, Field, Constructor) to their corresponding
info wrapper objects (ClassInfo, MethodInfo, FieldInfo, ConstructorInfo).
Features:
- Convenient factory methods - convert reflection objects to info wrappers
- Null-safe - methods handle
null inputs gracefully - Unified API - consistent method naming across all reflection types
Use Cases:
- Converting reflection objects to info wrappers in a consistent way
- Simplifying code that works with both reflection and info objects
- Providing a centralized location for reflection-to-info conversions
Usage:
Null Handling:
All methods in this class handle
See Also:
ClassInfo- Class introspection wrapperMethodInfo- Method introspection wrapperFieldInfo- Field introspection wrapperConstructorInfo- Constructor introspection wrapper- Reflection Package
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic final <T> ClassInfoTyped<T>Returns theClassInfowrapper for the specified class.static final ClassInfoReturns theClassInfowrapper for the class of the specified object.static final ConstructorInfoinfo(Constructor<?> o) Returns theConstructorInfowrapper for the specified constructor.static final FieldInfoReturns theFieldInfowrapper for the specified field.static final MethodInfoReturns theMethodInfowrapper for the specified method.
-
Constructor Details
-
ReflectionUtils
public ReflectionUtils()
-
-
Method Details
-
info
Returns theClassInfowrapper for the specified class.Example:
ClassInfo
ci = ReflectionUtils.info (MyClass.class );- Parameters:
o- The class to wrap. Can benull .- Returns:
- The
ClassInfowrapper, ornull if the input isnull .
-
info
Returns theConstructorInfowrapper for the specified constructor.Example:
Constructor<?>
c = MyClass.class .getConstructor(); ConstructorInfoci = ReflectionUtils.info (c );- Parameters:
o- The constructor to wrap. Can benull .- Returns:
- The
ConstructorInfowrapper, ornull if the input isnull .
-
info
Returns theFieldInfowrapper for the specified field.Example:
Field
f = MyClass.class .getField("myField" ); FieldInfofi = ReflectionUtils.info (f );- Parameters:
o- The field to wrap. Can benull .- Returns:
- The
FieldInfowrapper, ornull if the input isnull .
-
info
Returns theMethodInfowrapper for the specified method.Example:
Method
m = MyClass.class .getMethod("myMethod" ); MethodInfomi = ReflectionUtils.info (m );- Parameters:
o- The method to wrap. Can benull .- Returns:
- The
MethodInfowrapper, ornull if the input isnull .
-
info
Returns theClassInfowrapper for the class of the specified object.Example:
MyClass
obj =new MyClass(); ClassInfoci = ReflectionUtils.info (obj );- Parameters:
o- The object whose class to wrap. Can benull .- Returns:
- The
ClassInfowrapper for the object's class, ornull if the input isnull .
-