Interface IMetaOperation
-
- All Known Subinterfaces:
IResolvableOperation<V>
- All Known Implementing Classes:
AbstractIvmlTypeOperationDescriptor,AbstractRule,CompoundTypeDescriptor.ConstructorOperationDescriptor,CompoundTypeDescriptor.TypeOperationDescriptor,Def,FakeOperationDescriptor,IvmlComparisonOperationDescriptor,IvmlConfigurationConversionOperationDescriptor,IvmlConfigurationOperationDescriptor,IvmlConstructorOperationDescriptor,IvmlConversionOperationDescriptor,IvmlOperationDescriptor,IvmlOrderedEnumComparisonOperationDescriptor,IvmlOrderedEnumMinMaxOperationDescriptor,IvmlSequenceConversionOperationDescriptor,IvmlSetConversionOperationDescriptor,IvmlToStringConversionOperationDescriptor,OperationDescriptor,ReflectionConstructorDescriptor,ReflectionOperationDescriptor,Rule,VtlRule
public interface IMetaOperationDescribes an operation defined for aIMetaType. This interface is used for generic type compliance checks. Please note that named arguments are passed in terms of a map as the last parameter of the respective method. If the underlying Java method takes such a parameter, the descriptor will count one parameter less!- Author:
- Holger Eichelberger
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classIMetaOperation.CompatibilityResultReturns the result of a type compatibility comparison.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description booleanacceptsNamedParameters()Returns whether the operation accepts named parameters.IMetaTypegetDeclaringType()Returns the declaring type.java.lang.StringgetJavaSignature()Returns the java-like signature of this operation.java.lang.StringgetName()Returns the name of the method.IMetaParameterDeclarationgetParameter(java.lang.String name)Returns a named parameter declaration.intgetParameterCount()Returns the number of parameters.IMetaTypegetParameterType(int index)Returns the specified parameter type.intgetRequiredParameterCount()Returns the number of required parameters, i.e., non-default and non-named parameters.IMetaTypegetReturnType()Returns the return type of this operation.java.lang.StringgetSignature()Returns the signature of the method (in terms of VIL types where possible).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.booleanisConstructor()Returns whether this operation represents a constructor.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.
-
-
-
Method Detail
-
getName
java.lang.String getName()
Returns the name of the method.- Returns:
- the name of the method
-
isStatic
boolean isStatic()
Returns whether this operation is static.- Returns:
trueif it is static,falseelse
-
isFirstParameterOperand
boolean isFirstParameterOperand()
Returns whether the first parameter is the operand.- Returns:
trueif the first parameter is the operand,falseelse
-
getParameterCount
int getParameterCount()
Returns the number of parameters.- Returns:
- the number of parameter
-
getRequiredParameterCount
int getRequiredParameterCount()
Returns the number of required parameters, i.e., non-default and non-named parameters.- Returns:
- the number of required parameters
-
getParameter
IMetaParameterDeclaration getParameter(java.lang.String name)
Returns a named parameter declaration.- Parameters:
name- the name of the parameter- Returns:
- the declaration or null if there is none
-
getParameterType
IMetaType getParameterType(int index)
Returns the specified parameter type.- Parameters:
index- the index of the parameter to return- Returns:
- the specified parameter type
- Throws:
java.lang.IndexOutOfBoundsException- ifindex < 0 || index >=getParameterCount()
-
getJavaSignature
java.lang.String getJavaSignature()
Returns the java-like signature of this operation.- Returns:
- the java-like Java signature of this operation
-
getSignature
java.lang.String getSignature()
Returns the signature of the method (in terms of VIL types where possible).- Returns:
- the signature of the method
-
getReturnType
IMetaType getReturnType()
Returns the return type of this operation.- Returns:
- the return type
-
acceptsNamedParameters
boolean acceptsNamedParameters()
Returns whether the operation accepts named parameters.- Returns:
trueif it accepts named parameters,falseelse
-
getDeclaringType
IMetaType getDeclaringType()
Returns the declaring type.- Returns:
- the declaring type (may be null in case of a wrapped external Java method)
-
isPlaceholder
boolean isPlaceholder()
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.- Returns:
trueif this operation is a placeholder,falseelse
-
isConstructor
boolean isConstructor()
Returns whether this operation represents a constructor. Basically, for VIL a constructor is a public static method named "create" which returns an instance of the underlying type. Declared constructors are used for internal purposes.- Returns:
trueif this operation is a "constructor",falseelse
-
isCompatible
IMetaOperation.CompatibilityResult isCompatible(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. This method does not consider possible unnamed parameter rather than the underlying Java parameter.- 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
java.lang.Object invoke(java.lang.Object... args) throws VilExceptionInvokes the specified operation. This method does not consider possible unnamed parameter rather than the underlying Java parameter. In case ofacceptsNamedParameters()the caller must ensure that the last parameter is amap<String, Object>containing the named parameters.- 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:
isCompatible(java.lang.Class<?>, java.lang.Object...)
-
-