com.threerings.presents.util
Class ClassUtil

java.lang.Object
  extended by com.threerings.presents.util.ClassUtil

public class ClassUtil
extends Object

Class related utility functions.


Constructor Summary
ClassUtil()
           
 
Method Summary
static Method findMethod(Class<?> clazz, String name)
          Locates and returns the first method in the supplied class whose name is equal to the specified name.
static Method getMethod(String name, Object target, Map<String,Method> cache)
          Locates and returns the first method in the supplied class whose name is equal to the specified name.
static Method getMethod(String name, Object target, Object[] args)
          Looks up the method on the specified object that has a signature that matches the supplied arguments array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClassUtil

public ClassUtil()
Method Detail

getMethod

public static Method getMethod(String name,
                               Object target,
                               Map<String,Method> cache)
Locates and returns the first method in the supplied class whose name is equal to the specified name. If a method is located, it will be cached in the supplied cache so that subsequent requests will immediately return the method from the cache rather than re-reflecting.

Returns:
the method with the specified name or null if no method with that name could be found.

getMethod

public static Method getMethod(String name,
                               Object target,
                               Object[] args)
Looks up the method on the specified object that has a signature that matches the supplied arguments array. This is very expensive, so you shouldn't be doing this for something that happens frequently.

Returns:
the best matching method with the specified name that accepts the supplied arguments, or null if no method could be found.
See Also:
MethodFinder

findMethod

public static Method findMethod(Class<?> clazz,
                                String name)
Locates and returns the first method in the supplied class whose name is equal to the specified name.

Returns:
the method with the specified name or null if no method with that name could be found.