com.acciente.induction.util
Class ReflectUtils

java.lang.Object
  extended by com.acciente.induction.util.ReflectUtils

public class ReflectUtils
extends Object

Internal. Some useful reflection methods. (It is not convincing enough at this time that these methods are general enough to be promoted to the com.acciente.reflect package)

Author:
Adinath Raveendra Raj

Constructor Summary
ReflectUtils()
           
 
Method Summary
static Constructor getNoArgConstructor(Class oClass)
          This method introspects into the specified class and checks if the class has a public constructor with formal parameters (i.e.
static Constructor getSingletonConstructor(Class oClass)
          This method introspects into the specified class and checks if the class has only one public constructor.
static Method getSingletonMethod(Class oClass, String sMethodName)
          This method introspects into the specified class and checks if the class has only one public method with the specified name.
static Method getSingletonMethod(Class oClass, String sMethodName, boolean bIgnoreCase)
          This method introspects into the specified class and checks if the class has only one public method with the specified name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReflectUtils

public ReflectUtils()
Method Detail

getSingletonConstructor

public static Constructor getSingletonConstructor(Class oClass)
                                           throws ConstructorNotFoundException
This method introspects into the specified class and checks if the class has only one public constructor. If one one constructor is found it is returned otherwise an exception is thrown.

Parameters:
oClass - the class to introspect into
Returns:
the single public constructor
Throws:
ConstructorNotFoundException - if there are no public constructors or if there is more than one public constructor

getNoArgConstructor

public static Constructor getNoArgConstructor(Class oClass)
                                       throws ConstructorNotFoundException
This method introspects into the specified class and checks if the class has a public constructor with formal parameters (i.e. a no-arg constructor). If found it is returned otherwise an exception is thrown.

Parameters:
oClass - the class to introspect into
Returns:
the no-arg constructor
Throws:
ConstructorNotFoundException - if there are no no-arg constructors

getSingletonMethod

public static Method getSingletonMethod(Class oClass,
                                        String sMethodName)
                                 throws MethodNotFoundException
This method introspects into the specified class and checks if the class has only one public method with the specified name. If one one method is found it is returned otherwise an IllegalArgumentException is thrown.

Parameters:
oClass - the class to introspect into
sMethodName - the name of the method (case-sensitive)
Returns:
the single public method found
Throws:
MethodNotFoundException - if there are no public methods with the specified name or if there is more than one public method with the specified name

getSingletonMethod

public static Method getSingletonMethod(Class oClass,
                                        String sMethodName,
                                        boolean bIgnoreCase)
                                 throws MethodNotFoundException
This method introspects into the specified class and checks if the class has only one public method with the specified name. If one one method is found it is returned otherwise an IllegalArgumentException is thrown.

Parameters:
oClass - the class to introspect into
sMethodName - the name of the method
bIgnoreCase - true if the method search should be case-sensitive
Returns:
the single public method found
Throws:
MethodNotFoundException - if there are no public methods with the specified name or if there is more than one public method with the specified name


Copyright © 2008-2013 Acciente, LLC. All Rights Reserved.