Class ReflectionConstructorDescriptor
- java.lang.Object
-
- net.ssehub.easy.instantiation.core.model.vilTypes.OperationDescriptor
-
- net.ssehub.easy.instantiation.core.model.vilTypes.ReflectionConstructorDescriptor
-
- All Implemented Interfaces:
ILazyDescriptor,IMetaOperation
public class ReflectionConstructorDescriptor extends OperationDescriptor implements ILazyDescriptor
Implements a reflection constructor descriptor.- Author:
- Holger Eichelberger
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class net.ssehub.easy.instantiation.core.model.vilTypes.OperationDescriptor
OperationDescriptor.AliasType
-
Nested classes/interfaces inherited from interface net.ssehub.easy.instantiation.core.model.vilTypes.IMetaOperation
IMetaOperation.CompatibilityResult
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.reflect.Constructor<?>constructor-
Fields inherited from class net.ssehub.easy.instantiation.core.model.vilTypes.OperationDescriptor
CONSTRUCTOR_NAME, EMPTY_PARAMETER
-
-
Constructor Summary
Constructors Constructor Description ReflectionConstructorDescriptor(TypeDescriptor<?> declaringType, java.lang.reflect.Constructor<?> constructor)Creates a reflection constructor descriptor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidforceInitialization()Forces the initialization of the typically lazily deferred parameters and return types.protected java.lang.reflect.Constructor<?>getConstructor()Returns the wrapped constructor.protected java.lang.StringgetDeclaringTypeNameFallback()Returns the name of the declaring type in case thatOperationDescriptor.getDeclaringType()is null.java.lang.StringgetJavaSignature()Returns the Java signature of the method (public for testing).protected java.lang.Class<?>[]getParameterGenerics(int index)Determines the generic type of a parameter.protected voidinitializeParameters()Initializes the parameters (lazy init).protected voidinitializeReturnType()Initializes the return type (lazy init).java.lang.Objectinvoke(java.lang.Object... args)Invokes the specified operation.IMetaOperation.CompatibilityResultisCompatible(java.lang.Class<?> retType, java.lang.Object... params)Returns whether the operation represented by this instance is compatible to the given return type and parameters.booleanisFirstParameterOperand()Returns whether the first parameter is the operand.booleanisPlaceholder()Returns whether this operation is valid or whether it is a placeholder operation in case that the original operation cannot be resolved but the script shall remain executable.booleanisStatic()Returns whether this operation is static.booleanstoreArtifactsBeforeExecution()Returns whether artifacts shall be stored before execution of this operation.intuseGenericParameterAsReturn()Returns whether a generc parameter of the operand shall be used as return type.intuseParameterAsReturn()Returns whether a parameter shall be used as return type.-
Methods inherited from class net.ssehub.easy.instantiation.core.model.vilTypes.OperationDescriptor
acceptsImplicitParameters, acceptsNamedParameters, allowsAggregation, composeExceptionMessage, convertVariables, flatten, getAliasType, getDeclaringType, getDeclaringTypeName, getName, getOperationType, getParameter, getParameter, getParameterCount, getParameterType, getRequiredParameterCount, getReturnType, getSignature, getStoredName, isAlias, isConstructor, isConstructor, isConversion, isGenericCollectionOperation, isIteratingCollectionOperation, isOclCompliant, isOperation, isOperationOrConstructor, isSameSignature, isTypeSelect, requiresDynamicExpressionProcessing, setCharacteristics, setParameters, setReturnType, specializeFor, throwIncompatibleParameter, toString, trace, useAny, useOperandTypeAsParameter
-
-
-
-
Constructor Detail
-
ReflectionConstructorDescriptor
public ReflectionConstructorDescriptor(TypeDescriptor<?> declaringType, java.lang.reflect.Constructor<?> constructor)
Creates a reflection constructor descriptor.- Parameters:
declaringType- the declaring typeconstructor- the constructor
-
-
Method Detail
-
isStatic
public boolean isStatic()
Description copied from interface:IMetaOperationReturns whether this operation is static.- Specified by:
isStaticin interfaceIMetaOperation- Returns:
trueif it is static,falseelse
-
isFirstParameterOperand
public boolean isFirstParameterOperand()
Description copied from interface:IMetaOperationReturns whether the first parameter is the operand.- Specified by:
isFirstParameterOperandin interfaceIMetaOperation- Returns:
trueif the first parameter is the operand,falseelse
-
isPlaceholder
public boolean isPlaceholder()
Description copied from interface:IMetaOperationReturns whether this operation is valid or whether it is a placeholder operation in case that the original operation cannot be resolved but the script shall remain executable.- Specified by:
isPlaceholderin interfaceIMetaOperation- Returns:
trueif this operation is a placeholder,falseelse
-
initializeParameters
protected void initializeParameters()
Description copied from class:OperationDescriptorInitializes the parameters (lazy init). Is called byOperationDescriptor.initialize(). Shall callOperationDescriptor.setParameters(List, boolean, boolean).- Specified by:
initializeParametersin classOperationDescriptor
-
getParameterGenerics
protected java.lang.Class<?>[] getParameterGenerics(int index)
Determines the generic type of a parameter.- Parameters:
index- the index of the parameter- Returns:
- the generics (null if none are specified)
- Throws:
java.lang.IndexOutOfBoundsException- ifindex < 0 || index >=OperationDescriptor.getParameterCount()
-
initializeReturnType
protected void initializeReturnType()
Description copied from class:OperationDescriptorInitializes the return type (lazy init). Is called byOperationDescriptor.initialize(). Shall callOperationDescriptor.setReturnType(TypeDescriptor).- Specified by:
initializeReturnTypein classOperationDescriptor
-
getDeclaringTypeNameFallback
protected java.lang.String getDeclaringTypeNameFallback()
Description copied from class:OperationDescriptorReturns the name of the declaring type in case thatOperationDescriptor.getDeclaringType()is null.- Specified by:
getDeclaringTypeNameFallbackin classOperationDescriptor- Returns:
- the name of the declaring type
-
getJavaSignature
public java.lang.String getJavaSignature()
Description copied from class:OperationDescriptorReturns the Java signature of the method (public for testing).- Specified by:
getJavaSignaturein interfaceIMetaOperation- Specified by:
getJavaSignaturein classOperationDescriptor- Returns:
- the Java signature of the method
-
isCompatible
public IMetaOperation.CompatibilityResult isCompatible(java.lang.Class<?> retType, java.lang.Object... params)
Description copied from interface:IMetaOperationReturns whether the operation represented by this instance is compatible to the given return type and parameters. This method does not consider possible unnamed parameter rather than the underlying Java parameter.- Specified by:
isCompatiblein interfaceIMetaOperation- Parameters:
retType- the return type (may be null in order to ignore this parameter)params- the parameters (may be null if there are none, may be classes)- Returns:
- an instance of
IMetaOperation.CompatibilityResultdenoting the actual compatibility level
-
invoke
public java.lang.Object invoke(java.lang.Object... args) throws VilExceptionDescription copied from interface:IMetaOperationInvokes the specified operation. This method does not consider possible unnamed parameter rather than the underlying Java parameter. In case ofIMetaOperation.acceptsNamedParameters()the caller must ensure that the last parameter is amap<String, Object>containing the named parameters.- Specified by:
invokein interfaceIMetaOperation- Parameters:
args- the arguments, in case of non-static operations the first argument must be the object to execute on- Returns:
- the result of the execution
- Throws:
VilException- if the invocation fails- See Also:
IMetaOperation.isCompatible(java.lang.Class<?>, java.lang.Object...)
-
useGenericParameterAsReturn
public int useGenericParameterAsReturn()
Description copied from class:OperationDescriptorReturns whether a generc parameter of the operand shall be used as return type.- Specified by:
useGenericParameterAsReturnin classOperationDescriptor- Returns:
- the parameter to be used as index number, negative if none
-
useParameterAsReturn
public int useParameterAsReturn()
Description copied from class:OperationDescriptorReturns whether a parameter shall be used as return type.- Specified by:
useParameterAsReturnin classOperationDescriptor- Returns:
- the parameter to be used as index number, negative if none
-
storeArtifactsBeforeExecution
public boolean storeArtifactsBeforeExecution()
Description copied from class:OperationDescriptorReturns whether artifacts shall be stored before execution of this operation.- Specified by:
storeArtifactsBeforeExecutionin classOperationDescriptor- Returns:
trueif artifacts shall be stored,falseelse
-
forceInitialization
public void forceInitialization()
Description copied from interface:ILazyDescriptorForces the initialization of the typically lazily deferred parameters and return types.- Specified by:
forceInitializationin interfaceILazyDescriptor
-
getConstructor
protected java.lang.reflect.Constructor<?> getConstructor()
Returns the wrapped constructor.- Returns:
- the wrapped constructor
-
-