Class ClassWrapper
- java.lang.Object
-
- net.ssehub.easy.instantiation.core.model.vilTypes.ClassWrapper
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.Class<?>clsprivate OperationDescriptor[]operationsprivate TypeRegistryregistry
-
Constructor Summary
Constructors Constructor Description ClassWrapper(java.lang.Class<?> cls, TypeRegistry registry)Creates a new class wrapper for the given class.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description IMetaOperationaddPlaceholderOperation(java.lang.String name, int parameterCount, boolean acceptsNamedParameters)Adds a placeholder operation, i.e., in case that the original operation cannot be resolved but the script shall remain executable.booleancheckConversion(IMetaType param, IMetaOperation conversion)Checks a conversion from this type toparamvia the givenconversion.booleanenableDynamicDispatch()Returns whether this type enables dynamic dispatch of operations.IMetaOperationfindConversion(IMetaType sourceType, IMetaType targetType)Returns the conversion operation from this type to target type (if there is any).IMetaTypegetBaseType()Returns the base type (in case of IVML derived types).java.util.List<IMetaOperation>getCandidates(java.lang.String name, int unnamedArgsCount)Returns operation candidates matching the given name and number of unnamed (required) arguments.IMetaFieldgetField(int index)Returns the specified field.intgetFieldCount()Returns the number of fields provided by this type.intgetGenericParameterCount()Returns the number of generic type parameters.TypeDescriptor<?>getGenericParameterType(int index)Returns the specified generic parameter type.java.lang.StringgetName()Returns the (simple) name of this type.IMetaOperationgetOperation(int index)Returns the specified operation.intgetOperationsCount()Returns the number of operations provided by this type.java.lang.StringgetQualifiedName()Returns the qualified name of this type.IMetaTypegetSuperType()Returns the type this type is refined from.TypeRegistrygetTypeRegistry()Returns the type registry this type was registered by.java.lang.Class<?>getWrappedClass()Returns the class of the wrapped class.booleanisActualTypeOf(IMetaType type)Returns whether this type can act as an actual type oftype.booleanisAssignableFrom(IMetaType type)Returns whether this type is the same or a super class oftype.booleanisBasicType()Returns whether this instance represents a basic type.booleanisInternal()Returns whether this type is internal and shall not be visible to the user.booleanisPlaceholder()Returns whether this type is valid or whether it is a placeholder type in case that the original type cannot be resolved but the script shall remain executable.
-
-
-
Field Detail
-
cls
private java.lang.Class<?> cls
-
operations
private OperationDescriptor[] operations
-
registry
private TypeRegistry registry
-
-
Constructor Detail
-
ClassWrapper
public ClassWrapper(java.lang.Class<?> cls, TypeRegistry registry)Creates a new class wrapper for the given class.- Parameters:
cls- the class to be wrappedregistry- the registry this wrapper is registered with
-
-
Method Detail
-
getName
public java.lang.String getName()
Description copied from interface:IMetaTypeReturns the (simple) name of this type.
-
getQualifiedName
public java.lang.String getQualifiedName()
Description copied from interface:IMetaTypeReturns the qualified name of this type.- Specified by:
getQualifiedNamein interfaceIMetaType- Returns:
- the qualified name
-
getOperationsCount
public int getOperationsCount()
Description copied from interface:IMetaTypeReturns the number of operations provided by this type.- Specified by:
getOperationsCountin interfaceIMetaType- Returns:
- the number of operations
-
getOperation
public IMetaOperation getOperation(int index)
Description copied from interface:IMetaTypeReturns the specified operation.- Specified by:
getOperationin interfaceIMetaType- Parameters:
index- the 0-based index of the operation to be returned- Returns:
- the specified operation
-
isAssignableFrom
public boolean isAssignableFrom(IMetaType type)
Description copied from interface:IMetaTypeReturns whether this type is the same or a super class oftype.- Specified by:
isAssignableFromin interfaceIMetaType- Parameters:
type- the descriptor to be tested- Returns:
trueif both types are assignment compatible,falseelse
-
findConversion
public IMetaOperation findConversion(IMetaType sourceType, IMetaType targetType)
Description copied from interface:IMetaTypeReturns the conversion operation from this type to target type (if there is any).- Specified by:
findConversionin interfaceIMetaType- Parameters:
sourceType- the source type to convert fromtargetType- the target type to convert to- Returns:
- the conversion operation as defined in the underlying implementation class, null if no matching can be found
-
isBasicType
public boolean isBasicType()
Description copied from interface:IMetaTypeReturns whether this instance represents a basic type.- Specified by:
isBasicTypein interfaceIMetaType- Returns:
trueif this instance represents a basic type,falseelse
-
getTypeRegistry
public TypeRegistry getTypeRegistry()
Description copied from interface:IMetaTypeReturns the type registry this type was registered by.- Specified by:
getTypeRegistryin interfaceIMetaType- Returns:
- the type registry
-
enableDynamicDispatch
public boolean enableDynamicDispatch()
Description copied from interface:IMetaTypeReturns whether this type enables dynamic dispatch of operations.- Specified by:
enableDynamicDispatchin interfaceIMetaType- Returns:
trueif it enables dynamic dispatch,falseelse
-
isPlaceholder
public boolean isPlaceholder()
Description copied from interface:IMetaTypeReturns whether this type is valid or whether it is a placeholder type in case that the original type cannot be resolved but the script shall remain executable.- Specified by:
isPlaceholderin interfaceIMetaType- Returns:
trueif this type is a placeholder,falseelse
-
addPlaceholderOperation
public IMetaOperation addPlaceholderOperation(java.lang.String name, int parameterCount, boolean acceptsNamedParameters)
Description copied from interface:IMetaTypeAdds a placeholder operation, i.e., in case that the original operation cannot be resolved but the script shall remain executable.- Specified by:
addPlaceholderOperationin interfaceIMetaType- Parameters:
name- the name of the operationparameterCount- the number of parameters of the operationacceptsNamedParameters- whether the operation shall accept named parameters- Returns:
- the added operation, null if this type is not a
placeholder
-
isActualTypeOf
public boolean isActualTypeOf(IMetaType type)
Description copied from interface:IMetaTypeReturns whether this type can act as an actual type oftype.- Specified by:
isActualTypeOfin interfaceIMetaType- Parameters:
type- the type to be checked- Returns:
trueif this type can act as an actual type oftype,falseelse- See Also:
IActualTypeProvider
-
getBaseType
public IMetaType getBaseType()
Description copied from interface:IMetaTypeReturns the base type (in case of IVML derived types).- Specified by:
getBaseTypein interfaceIMetaType- Returns:
- the base type or null
-
getFieldCount
public int getFieldCount()
Description copied from interface:IMetaTypeReturns the number of fields provided by this type.- Specified by:
getFieldCountin interfaceIMetaType- Returns:
- the number of fields
-
getField
public IMetaField getField(int index)
Description copied from interface:IMetaTypeReturns the specified field.
-
isInternal
public boolean isInternal()
Description copied from interface:IMetaTypeReturns whether this type is internal and shall not be visible to the user.- Specified by:
isInternalin interfaceIMetaType- Returns:
trueif this type is internal,falseelse
-
getWrappedClass
public java.lang.Class<?> getWrappedClass()
Returns the class of the wrapped class.- Returns:
- class
-
getSuperType
public IMetaType getSuperType()
Description copied from interface:IMetaTypeReturns the type this type is refined from.- Specified by:
getSuperTypein interfaceIMetaType- Returns:
- the super type or null if there is none
-
getGenericParameterCount
public int getGenericParameterCount()
Description copied from interface:IMetaTypeReturns the number of generic type parameters.- Specified by:
getGenericParameterCountin interfaceIMetaType- Returns:
- the number of generic type parameters
-
getGenericParameterType
public TypeDescriptor<?> getGenericParameterType(int index)
Description copied from interface:IMetaTypeReturns the specified generic parameter type.- Specified by:
getGenericParameterTypein interfaceIMetaType- Parameters:
index- the index of the parameter type to return- Returns:
- the specified parameter type
-
checkConversion
public boolean checkConversion(IMetaType param, IMetaOperation conversion)
Description copied from interface:IMetaTypeChecks a conversion from this type toparamvia the givenconversion.- Specified by:
checkConversionin interfaceIMetaType- Parameters:
param- the original parameter valueconversion- the conversion function- Returns:
trueif ok,falseelse
-
getCandidates
public java.util.List<IMetaOperation> getCandidates(java.lang.String name, int unnamedArgsCount)
Description copied from interface:IMetaTypeReturns operation candidates matching the given name and number of unnamed (required) arguments.- Specified by:
getCandidatesin interfaceIMetaType- Parameters:
name- the name of the operationunnamedArgsCount- the number of unnamed arguments- Returns:
- the operation candidates
-
-