Class IvmlTypeDescriptor
- java.lang.Object
-
- net.ssehub.easy.instantiation.core.model.vilTypes.TypeDescriptor<DecisionVariable>
-
- net.ssehub.easy.instantiation.core.model.vilTypes.configuration.AbstractIvmlTypeDescriptor
-
- net.ssehub.easy.instantiation.core.model.vilTypes.configuration.IvmlTypeDescriptor
-
- All Implemented Interfaces:
IActualTypeAssignmentProvider,IMetaType
public class IvmlTypeDescriptor extends AbstractIvmlTypeDescriptor implements IActualTypeAssignmentProvider
Implements a dynamic type descriptor for IVML decision variables. Instances of this class represent IVML types and act as a frontend forDecisionVariable, thus,decision variablesare assignable.- Author:
- Holger Eichelberger
-
-
Field Summary
Fields Modifier and Type Field Description private TypeDescriptor<?>baseTypeprivate IDatatypetype-
Fields inherited from class net.ssehub.easy.instantiation.core.model.vilTypes.TypeDescriptor
EMPTY
-
-
Constructor Summary
Constructors Constructor Description IvmlTypeDescriptor()For serialization.IvmlTypeDescriptor(Project project, IDatatype ivmlType, IvmlTypeResolver resolver)Creates a new type descriptor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidaddCompoundOperations(IDatatype ivmlType, java.util.Map<java.lang.String,OperationDescriptor> operations, java.util.Map<java.lang.String,FieldDescriptor> fields)Adds the operations for compound types if needed.private voidaddDerivedTypeConversions(IDatatype ivmlType, java.util.List<OperationDescriptor> conversions)Adds the conversion operations for derived types if needed.private voidaddElements(IDecisionVariableContainer container, TypeRegistry registry, java.util.Map<java.lang.String,FieldDescriptor> fields)Adds all the elements in this container and recursively processes attribute assignments.private voidaddEnumOperations(IDatatype ivmlType, java.util.Map<java.lang.String,OperationDescriptor> operations)Adds the operations for enumeration types if needed.OperationDescriptoraddPlaceholderOperation(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.Set<?>allInstances()Provides access to all instances of this type.booleancheckConversion(IMetaType param, IMetaOperation conversion)Checks a conversion from this type toparamvia the givenconversion.IMetaTypegetBaseType()Returns the base type (in case of IVML derived types).private IDatatypegetDatatype(java.lang.Object object)Returns the datatype forobject.protected IDatatypegetIvmlType()Returns the underlying IVML type.booleanisAssignableFrom(IMetaType type1, IMetaType type2)Returns whether type1 is a super class of or equal totype2.booleanisAssignableFrom(TypeDescriptor<?> desc)Returns whether this descriptor is the same or a super class ofdesc.booleanisInstance(java.lang.Object object)Returns whether the givenobjectis an instance of this descriptor.booleanisInstantiator()Returns whether this type is an instantiator.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.booleanisSameType(java.lang.Object object)Returns whether the givenobjectof of the type of this descriptor.booleanisSequence()Returns whether this descriptor represents a VIL sequence.booleanisSet()Returns whether this descriptor represents a VIL set.(package private) voidresolve(Project project, IDatatype ivmlType, java.util.Set<Attribute> declaredAttributes)Resolves the type descriptor by filling it with operations and fields.-
Methods inherited from class net.ssehub.easy.instantiation.core.model.vilTypes.configuration.AbstractIvmlTypeDescriptor
addAttributeFields, addComparisonOperations, addConversionOperations, addDecisionVariableOperations, canBeInstantiated, create, getDefaultValue, getRefines, getSuperType, getTypeClass, getTypeRegistry, isActualTypeOf, isAssignableFrom, isBasicType, isCollection, isEqual, isIterator, isMap, setRefines
-
Methods inherited from class net.ssehub.easy.instantiation.core.model.vilTypes.TypeDescriptor
addOperation, appendParameter, createArray, enableDynamicDispatch, findCollectionIteratorOperation, findConversion, findConversion, findConversionOnBoth, flatten, flattenParam, getCandidates, getCandidates, getConversion, getConversions, getConversionsCount, getConversionToSequence, getField, getField, getFieldCount, getFields, getGenericParameter, getGenericParameterCount, getGenericParameterType, getName, getOperation, getOperations, getOperationsCount, getQualifiedName, getVilName, isFieldsNull, isInitialized, isNameSet, isSame, setConversions, setFields, setFields, setName, setOperations, toString
-
-
-
-
Field Detail
-
baseType
private TypeDescriptor<?> baseType
-
type
private IDatatype type
-
-
Constructor Detail
-
IvmlTypeDescriptor
IvmlTypeDescriptor() throws VilExceptionFor serialization.- Throws:
VilException- shall not occur
-
IvmlTypeDescriptor
IvmlTypeDescriptor(Project project, IDatatype ivmlType, IvmlTypeResolver resolver) throws VilException
Creates a new type descriptor.- Parameters:
project- the underlying IVML project the descriptor shall be created forivmlType- the IVML type to create the descriptor forresolver- for retrieving further IVML types- Throws:
VilException- if analyzing the class fails for some reason
-
-
Method Detail
-
resolve
void resolve(Project project, IDatatype ivmlType, java.util.Set<Attribute> declaredAttributes) throws VilException
Resolves the type descriptor by filling it with operations and fields. This method is separated from the constructor so that the type can be registered first and resolved then in order to enable parent resolution.- Parameters:
project- the underlying IVML project the descriptor shall be created forivmlType- the IVML type to resolve fordeclaredAttributes- attributes declared for all variables of that type, may be null- Throws:
VilException- if analyzing the underlying type fails for some reason
-
addCompoundOperations
private void addCompoundOperations(IDatatype ivmlType, java.util.Map<java.lang.String,OperationDescriptor> operations, java.util.Map<java.lang.String,FieldDescriptor> fields) throws VilException
Adds the operations for compound types if needed.- Parameters:
ivmlType- the type to processoperations- the operations (may be modified as a side effect)fields- the actually known fields ofivmlType(may be modified as a side effect)- Throws:
VilException- in case that creating fields for the elements fails
-
addEnumOperations
private void addEnumOperations(IDatatype ivmlType, java.util.Map<java.lang.String,OperationDescriptor> operations)
Adds the operations for enumeration types if needed.- Parameters:
ivmlType- the type to processoperations- the operations (may be modified as a side effect)
-
addDerivedTypeConversions
private void addDerivedTypeConversions(IDatatype ivmlType, java.util.List<OperationDescriptor> conversions)
Adds the conversion operations for derived types if needed.- Parameters:
ivmlType- the type to processconversions- the conversion operations (may be modified as a side effect)
-
addElements
private void addElements(IDecisionVariableContainer container, TypeRegistry registry, java.util.Map<java.lang.String,FieldDescriptor> fields) throws VilException
Adds all the elements in this container and recursively processes attribute assignments.- Parameters:
container- the containerregistry- the actual type registryfields- the name-field mapping to be modified as a side effect- Throws:
VilException- in case that creating fields for the elements fails
-
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
-
isAssignableFrom
public boolean isAssignableFrom(TypeDescriptor<?> desc)
Description copied from class:TypeDescriptorReturns whether this descriptor is the same or a super class ofdesc.- Specified by:
isAssignableFromin classTypeDescriptor<DecisionVariable>- Parameters:
desc- the descriptor to be tested- Returns:
trueif both descriptors are assignment compatible,falseelse
-
isSet
public boolean isSet()
Description copied from class:TypeDescriptorReturns whether this descriptor represents a VIL set.- Overrides:
isSetin classAbstractIvmlTypeDescriptor- Returns:
trueif this is a VIL set,falseelse
-
isSequence
public boolean isSequence()
Description copied from class:TypeDescriptorReturns whether this descriptor represents a VIL sequence.- Overrides:
isSequencein classAbstractIvmlTypeDescriptor- Returns:
trueif this is a VIL sequence,falseelse
-
getIvmlType
protected IDatatype getIvmlType()
Description copied from class:AbstractIvmlTypeDescriptorReturns the underlying IVML type.- Specified by:
getIvmlTypein classAbstractIvmlTypeDescriptor- Returns:
- the type
-
isAssignableFrom
public boolean isAssignableFrom(IMetaType type1, IMetaType type2)
Description copied from interface:IActualTypeAssignmentProviderReturns whether type1 is a super class of or equal totype2.- Specified by:
isAssignableFromin interfaceIActualTypeAssignmentProvider- Parameters:
type1- the first type to checktype2- the second type to check- Returns:
trueif assignable,falseelse
-
isInstance
public boolean isInstance(java.lang.Object object)
Description copied from class:TypeDescriptorReturns whether the givenobjectis an instance of this descriptor.- Specified by:
isInstancein classTypeDescriptor<DecisionVariable>- Parameters:
object- the object to be checked- Returns:
trueif it is an instance,falseelse
-
getDatatype
private IDatatype getDatatype(java.lang.Object object)
Returns the datatype forobject.- Parameters:
object- the object to return the datatype for- Returns:
- the datatype or null if there is none
-
isSameType
public boolean isSameType(java.lang.Object object)
Description copied from class:TypeDescriptorReturns whether the givenobjectof of the type of this descriptor.- Specified by:
isSameTypein classTypeDescriptor<DecisionVariable>- Parameters:
object- the object to be checked- Returns:
trueifobjecthas the same type,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 OperationDescriptor addPlaceholderOperation(java.lang.String name, int parameterCount, boolean acceptsNamedParameters)
Description copied from class:TypeDescriptorAdds a placeholder operation, i.e., in case that the original operation cannot be resolved but the script shall remain executable.- Specified by:
addPlaceholderOperationin interfaceIMetaType- Specified by:
addPlaceholderOperationin classTypeDescriptor<DecisionVariable>- Parameters:
name- the name of the operationparameterCount- the number of parameters of the operationacceptsNamedParameters- whether the operation accepts named parameters- Returns:
- the added operation, null if this type is not a
placeholder
-
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
-
isInstantiator
public boolean isInstantiator()
Description copied from class:TypeDescriptorReturns whether this type is an instantiator.- Specified by:
isInstantiatorin classTypeDescriptor<DecisionVariable>- Returns:
trueif it is an instantiator,falseelse
-
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
-
allInstances
public Set<?> allInstances()
Description copied from class:TypeDescriptorProvides access to all instances of this type.- Overrides:
allInstancesin classTypeDescriptor<DecisionVariable>- Returns:
- access to all instances (may be null if there are none)
-
-