org.mentabean.util
Class FindConstructor

java.lang.Object
  extended by org.mentabean.util.FindConstructor

public class FindConstructor
extends Object

Find constructor with polymorphism! Class.getConstructor only finds an exact match.

Author:
Jon Skeet (http://groups.google.com/group/comp.lang.java.programmer/browse_thread/thread/921ab91865c8cc2e/9e141d3d62e7cb3f)

Constructor Summary
FindConstructor()
           
 
Method Summary
static Constructor<? extends Object> getConstructor(Class<? extends Object> source, Class<? extends Object>[] parameterTypes)
          Finds the most specific applicable constructor
static Constructor<? extends Object> getDeclaredConstructor(Class<? extends Object> source, Class<? extends Object>[] parameterTypes)
          Finds the most specific applicable declared constructor
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FindConstructor

public FindConstructor()
Method Detail

getConstructor

public static Constructor<? extends Object> getConstructor(Class<? extends Object> source,
                                                           Class<? extends Object>[] parameterTypes)
                                                    throws NoSuchMethodException
Finds the most specific applicable constructor

Parameters:
source - Class to find a constructor for
parameterTypes - Parameter types to search for
Throws:
NoSuchMethodException

getDeclaredConstructor

public static Constructor<? extends Object> getDeclaredConstructor(Class<? extends Object> source,
                                                                   Class<? extends Object>[] parameterTypes)
                                                            throws NoSuchMethodException
Finds the most specific applicable declared constructor

Parameters:
source - Class to find method in
parameterTypes - Parameter types to search for
Throws:
NoSuchMethodException


Copyright © 2013. All Rights Reserved.