类 DefaultConstructorStrategy
java.lang.Object
com.obermuhlner.scriptengine.java.constructor.DefaultConstructorStrategy
- 所有已实现的接口:
ConstructorStrategy
The default
ConstructorStrategy implementation.
This implementation has three static constructor methods to define the constructor that should be called:
byDefaultConstructor()to call the public default no-argument constructor.byArgumentTypes(Class[], Object...)to call the public constructor with the specified argument types and pass it the specified arguments.byMatchingArguments(Object...)to call a public constructor that matches the specified arguments.
-
字段概要
字段 -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明static DefaultConstructorStrategybyArgumentTypes(Class<?>[] argumentTypes, Object... arguments) Creates aDefaultConstructorStrategythat will call the public constructor with the specified argument types and passes the specified argument list.static DefaultConstructorStrategyCreates aDefaultConstructorStrategythat will call the public default no-argument constructor.static DefaultConstructorStrategybyMatchingArguments(Object... arguments) Creates aDefaultConstructorStrategythat will call a public constructor that matches the specified arguments.Constructs an instance of aClass.private Constructor<?>findConstructor(Class<?> clazz, Class<?>[] argumentTypes, Object[] arguments)
-
字段详细资料
-
argumentTypes
-
arguments
-
-
构造器详细资料
-
DefaultConstructorStrategy
-
-
方法详细资料
-
construct
从接口复制的说明:ConstructorStrategyConstructs an instance of aClass.- 指定者:
construct在接口中ConstructorStrategy- 参数:
clazz- theClass- 返回:
- the constructed instance or
null - 抛出:
ScriptException- if the instance could not be constructed
-
byDefaultConstructor
Creates aDefaultConstructorStrategythat will call the public default no-argument constructor.- 返回:
- the created
DefaultConstructorStrategy
-
byArgumentTypes
public static DefaultConstructorStrategy byArgumentTypes(Class<?>[] argumentTypes, Object... arguments) Creates aDefaultConstructorStrategythat will call the public constructor with the specified argument types and passes the specified argument list.- 参数:
argumentTypes- the argument types defining the constructor to callarguments- the arguments to pass to the constructor (may containnull)- 返回:
- the created
DefaultConstructorStrategy
-
byMatchingArguments
Creates aDefaultConstructorStrategythat will call a public constructor that matches the specified arguments. A constructor must match all specified arguments, exceptnullvalues which match any non-primitive type. The conversion from object types into corresponding primitive types (for exampleIntegerintoint) is handled automatically. If multiple public constructors match the specified arguments theconstruct(Class)method will throw aScriptException.- 参数:
arguments- the arguments to pass to the constructor (may containnull)- 返回:
- the created
DefaultConstructorStrategy
-
findConstructor
private Constructor<?> findConstructor(Class<?> clazz, Class<?>[] argumentTypes, Object[] arguments) throws NoSuchMethodException, ScriptException
-