J avolution v5.5 (J2SE 1.6+)

javolution.lang
Interface Reflection.Constructor

Enclosing class:
Reflection

public static interface Reflection.Constructor

This interface represents a run-time constructor obtained through reflection. Here are few examples of utilization:

 // Default constructor (fastList = new FastList())
 Reflection.Constructor fastListConstructor
     = Reflection.getInstance().getConstructor("javolution.util.FastList()");
 Object fastList = fastListConstructor.newInstance();

 // Constructor with arguments (fastMap = new FastMap(64))
 Reflection.Constructor fastMapConstructor
     = Reflection.getInstance().getConstructor("javolution.util.FastMap(int)");
 Object fastMap = fastMapConstructor.newInstance(new Integer(64));
 


Method Summary
 java.lang.Class[] getParameterTypes()
          Returns an array of Class objects that represents the formal parameter types, in declaration order of this constructor.
 java.lang.Object newInstance()
          Invokes this constructor with no argument.
 java.lang.Object newInstance(java.lang.Object... args)
          Invokes this constructor with the specified arguments.
 java.lang.Object newInstance(java.lang.Object arg0)
          Invokes this constructor with the specified single argument.
 java.lang.Object newInstance(java.lang.Object arg0, java.lang.Object arg1)
          Invokes this constructor with the specified two arguments.
 java.lang.Object newInstance(java.lang.Object arg0, java.lang.Object arg1, java.lang.Object arg2)
          Invokes this constructor with the specified three arguments.
 

Method Detail

getParameterTypes

java.lang.Class[] getParameterTypes()
Returns an array of Class objects that represents the formal parameter types, in declaration order of this constructor.

Returns:
the parameter types for this constructor.

newInstance

java.lang.Object newInstance()
Invokes this constructor with no argument.

Returns:
the object being instantiated.
Throws:
java.lang.IllegalArgumentException - if this.getParametersTypes().length != 0

newInstance

java.lang.Object newInstance(java.lang.Object arg0)
Invokes this constructor with the specified single argument.

Parameters:
arg0 - the first argument.
Returns:
the object being instantiated.
Throws:
java.lang.IllegalArgumentException - if this.getParametersTypes().length != 1

newInstance

java.lang.Object newInstance(java.lang.Object arg0,
                             java.lang.Object arg1)
Invokes this constructor with the specified two arguments.

Parameters:
arg0 - the first argument.
arg1 - the second argument.
Returns:
the object being instantiated.
Throws:
java.lang.IllegalArgumentException - if this.getParametersTypes().length != 2

newInstance

java.lang.Object newInstance(java.lang.Object arg0,
                             java.lang.Object arg1,
                             java.lang.Object arg2)
Invokes this constructor with the specified three arguments.

Parameters:
arg0 - the first argument.
arg1 - the second argument.
arg2 - the third argument.
Returns:
the object being instantiated.
Throws:
java.lang.IllegalArgumentException - if this.getParametersTypes().length != 3

newInstance

java.lang.Object newInstance(java.lang.Object... args)
Invokes this constructor with the specified arguments.

Parameters:
args - the arguments.
Returns:
the object being instantiated.
Throws:
java.lang.IllegalArgumentException - if this.getParametersTypes().length != args.length

J avolution v5.5 (J2SE 1.6+)

Copyright © 2005 - 2009 Javolution.