public class ReflectionUtils
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.reflect.Method |
equals
the
Object.equals(Object) method. |
static java.lang.reflect.Method |
hashCode
the
Object.hashCode() method. |
static java.lang.reflect.Method |
toString
the
Object.toString() method. |
Modifier and Type | Method and Description |
---|---|
static void |
addIfClassProxyingSupportedAndNotObject(java.lang.Class clazz,
java.util.Set interfaces,
ProxyFactory proxyFactory)
Add the given type to the set of interfaces, if the given ProxyFactory supports proxy generation for this type.
|
static java.util.Set |
getAllInterfaces(java.lang.Class clazz)
Get all interfaces of the given type.
|
static java.util.Set |
getAllInterfaces(java.lang.Object[] objects)
Get all the interfaces implemented by a list of objects.
|
static java.lang.reflect.Method |
getMatchingMethod(java.lang.Class type,
java.lang.String methodName,
java.lang.Object[] args)
Get the method of the given type, that has matching parameter types to the given arguments.
|
static java.lang.Class |
getMostCommonSuperclass(java.lang.Object[] objects)
Get most common superclass for all given objects.
|
static java.lang.reflect.Method |
readMethod(java.io.ObjectInputStream in)
Read a
Method from an ObjectInputStream . |
static java.lang.Class[] |
toClassArray(java.util.Collection collection)
Convert the collection of class types to an array of class types.
|
static void |
writeMethod(java.io.ObjectOutputStream out,
java.lang.reflect.Method method)
Write a
Method into an ObjectOutputStream . |
public static final java.lang.reflect.Method equals
Object.equals(Object)
method.public static final java.lang.reflect.Method hashCode
Object.hashCode()
method.public static final java.lang.reflect.Method toString
Object.toString()
method.public static java.util.Set getAllInterfaces(java.lang.Object[] objects)
objects
- the list of objects to consider.public static java.util.Set getAllInterfaces(java.lang.Class clazz)
clazz
- type to explore.Set
with all interfaces. The set may be empty.public static java.lang.Class getMostCommonSuperclass(java.lang.Object[] objects)
objects
- the array of objects to consider.Void.class
for an empty array.public static void addIfClassProxyingSupportedAndNotObject(java.lang.Class clazz, java.util.Set interfaces, ProxyFactory proxyFactory)
clazz
- the class type (Object.class
will be ignored)interfaces
- the set of interfacesproxyFactory
- the ProxyFactory
in usepublic static java.lang.Class[] toClassArray(java.util.Collection collection)
collection
- with class typespublic static java.lang.reflect.Method getMatchingMethod(java.lang.Class type, java.lang.String methodName, java.lang.Object[] args) throws java.lang.NoSuchMethodException
type
- the typemethodName
- the name of the method to searchargs
- the arguments to matchMethod
java.lang.NoSuchMethodException
- if no matching Method
existspublic static void writeMethod(java.io.ObjectOutputStream out, java.lang.reflect.Method method) throws java.io.IOException
Method
into an ObjectOutputStream
.out
- the streammethod
- the Method
to writejava.io.IOException
- if writing causes a problempublic static java.lang.reflect.Method readMethod(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException
Method
from an ObjectInputStream
.in
- the streamMethod
java.io.IOException
- if reading causes a problemjava.lang.ClassNotFoundException
- if class types from objects of the InputStream cannot be foundjava.io.InvalidObjectException
- if the Method
cannot be found