Class CompoundTypeDescriptor
- java.lang.Object
-
- net.ssehub.easy.instantiation.core.model.vilTypes.TypeDescriptor<CompoundInstance>
-
- net.ssehub.easy.instantiation.core.model.vilTypes.CompoundTypeDescriptor
-
- All Implemented Interfaces:
IMetaType
public class CompoundTypeDescriptor extends TypeDescriptor<CompoundInstance>
Implements a compound type descriptor.- Author:
- Holger Eichelberger
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classCompoundTypeDescriptor.ConstructorOperationDescriptorThe constructor operation(s).static classCompoundTypeDescriptor.SlotDescriptorA slot field descriptor for compounds.private static classCompoundTypeDescriptor.TypeOperationDescriptorRepresents a type->name operation descriptor.
-
Field Summary
Fields Modifier and Type Field Description private booleanisAbstractprivate CompoundTypeDescriptorrefinesprivate TypeRegistryregistry-
Fields inherited from class net.ssehub.easy.instantiation.core.model.vilTypes.TypeDescriptor
EMPTY
-
-
Constructor Summary
Constructors Constructor Description CompoundTypeDescriptor(java.lang.String name, boolean isAbstract, CompoundTypeDescriptor refines, TypeRegistry registry)Creates a compound type descriptor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.booleancanBeInstantiated()Returns whetherTypeDescriptor.create(Object...)will return an instance.booleancheckConversion(IMetaType param, IMetaOperation conversion)Checks a conversion from this type toparamvia the givenconversion.CompoundInstancecreate(java.lang.Object... params)Creates an instance of the type according to the given parameters.IMetaTypegetBaseType()Returns the base type (in case of IVML derived types).FieldDescriptorgetDeclaredField(java.lang.String name)Returns the directly declared field with namename.CompoundTypeDescriptor.SlotDescriptorgetDeclaredSlot(java.lang.String name)Returns the directly declared slot with namename.FieldDescriptorgetField(java.lang.String name)Returns the field descriptor with the specified name.CompoundTypeDescriptorgetRefines()Returns the refined compound.CompoundTypeDescriptor.SlotDescriptorgetSlot(int index)Returns the specified slot descriptor.CompoundTypeDescriptor.SlotDescriptorgetSlot(java.lang.String name)Returns the slot descriptor with the specified name.intgetSlotCount()Returns the number of slots provided by this compound type.IMetaTypegetSuperType()Returns the type this type is refined from.java.lang.Class<CompoundInstance>getTypeClass()Returns the class of the described VIL type.TypeRegistrygetTypeRegistry()Returns the type registry this type was registered by.booleanisAbstract()Returns whether the compound is abstract.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.booleanisAssignableFrom(TypeDescriptor<?> desc)Returns whether this descriptor is the same or a super class ofdesc.booleanisBasicType()Returns whether this instance represents a basic type.booleanisCollection()Returns whether this descriptor represents a VIL collection, i.e., set, sequence or collection.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.booleanisIterator()Returns whether this descriptor represents an iterator.booleanisMap()Returns whether this descriptor represents a VIL map.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.voidsetFields(CompoundTypeDescriptor.SlotDescriptor[] slots)Sets the fields of this descriptor, only if there have no fields been defined at all so far.-
Methods inherited from class net.ssehub.easy.instantiation.core.model.vilTypes.TypeDescriptor
addOperation, allInstances, appendParameter, createArray, enableDynamicDispatch, findCollectionIteratorOperation, findConversion, findConversion, findConversionOnBoth, flatten, flattenParam, getCandidates, getCandidates, getConversion, getConversions, getConversionsCount, getConversionToSequence, getDefaultValue, getField, getFieldCount, getFields, getGenericParameter, getGenericParameterCount, getGenericParameterType, getName, getOperation, getOperations, getOperationsCount, getQualifiedName, getVilName, isFieldsNull, isInitialized, isNameSet, isSame, setConversions, setFields, setFields, setName, setOperations, toString
-
-
-
-
Field Detail
-
isAbstract
private boolean isAbstract
-
refines
private CompoundTypeDescriptor refines
-
registry
private TypeRegistry registry
-
-
Constructor Detail
-
CompoundTypeDescriptor
public CompoundTypeDescriptor(java.lang.String name, boolean isAbstract, CompoundTypeDescriptor refines, TypeRegistry registry) throws VilExceptionCreates a compound type descriptor.- Parameters:
name- the name of the typeisAbstract- if the type is abstractrefines- if there is a refined type (may be null for none)registry- the defining type registry- Throws:
VilException- in case of creation problems
-
-
Method Detail
-
isAssignableFrom
public boolean isAssignableFrom(IMetaType type)
Description copied from interface:IMetaTypeReturns whether this type is the same or a super class oftype.- Parameters:
type- the descriptor to be tested- Returns:
trueif both types are assignment compatible,falseelse
-
isBasicType
public boolean isBasicType()
Description copied from interface:IMetaTypeReturns whether this instance represents a basic type.- 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.- Returns:
- the type registry
-
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.- Returns:
trueif this type is a placeholder,falseelse
-
isActualTypeOf
public boolean isActualTypeOf(IMetaType type)
Description copied from interface:IMetaTypeReturns whether this type can act as an actual type oftype.- 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).- Returns:
- the base type or null
-
getSuperType
public IMetaType getSuperType()
Description copied from interface:IMetaTypeReturns the type this type is refined from.- Returns:
- the super type or null if there is none
-
getRefines
public CompoundTypeDescriptor getRefines()
Returns the refined compound.- Returns:
- the refined compound (may be null if there is none)
-
isInternal
public boolean isInternal()
Description copied from interface:IMetaTypeReturns whether this type is internal and shall not be visible to the user.- Returns:
trueif this type is internal,falseelse
-
checkConversion
public boolean checkConversion(IMetaType param, IMetaOperation conversion)
Description copied from interface:IMetaTypeChecks a conversion from this type toparamvia the givenconversion.- Parameters:
param- the original parameter valueconversion- the conversion function- Returns:
trueif ok,falseelse
-
getTypeClass
public java.lang.Class<CompoundInstance> getTypeClass()
Description copied from class:TypeDescriptorReturns the class of the described VIL type. Please use this method sparingly as the required functionality is provided by this class.- Specified by:
getTypeClassin classTypeDescriptor<CompoundInstance>- Returns:
- the class
-
canBeInstantiated
public boolean canBeInstantiated()
Description copied from class:TypeDescriptorReturns whetherTypeDescriptor.create(Object...)will return an instance.- Specified by:
canBeInstantiatedin classTypeDescriptor<CompoundInstance>- Returns:
trueif this type can be instantiated from VIL/VTL,falseelse
-
isAbstract
public boolean isAbstract()
Returns whether the compound is abstract.- Returns:
truefor abstract,falseelse
-
create
public CompoundInstance create(java.lang.Object... params) throws VilException
Description copied from class:TypeDescriptorCreates an instance of the type according to the given parameters.- Specified by:
createin classTypeDescriptor<CompoundInstance>- Parameters:
params- the parameters- Returns:
- the created instance
- Throws:
VilException- in case that the creation does not work
-
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<CompoundInstance>- Parameters:
desc- the descriptor to be tested- Returns:
trueif both descriptors are assignment compatible,falseelse
-
isMap
public boolean isMap()
Description copied from class:TypeDescriptorReturns whether this descriptor represents a VIL map.- Specified by:
isMapin classTypeDescriptor<CompoundInstance>- Returns:
trueif this is a VIL map,falseelse
-
isIterator
public boolean isIterator()
Description copied from class:TypeDescriptorReturns whether this descriptor represents an iterator.- Specified by:
isIteratorin classTypeDescriptor<CompoundInstance>- Returns:
trueif this is an iterator,falseelse
-
isCollection
public boolean isCollection()
Description copied from class:TypeDescriptorReturns whether this descriptor represents a VIL collection, i.e., set, sequence or collection.- Specified by:
isCollectionin classTypeDescriptor<CompoundInstance>- Returns:
trueif this is a VIL collection,falseelse
-
isSet
public boolean isSet()
Description copied from class:TypeDescriptorReturns whether this descriptor represents a VIL set.- Specified by:
isSetin classTypeDescriptor<CompoundInstance>- Returns:
trueif this is a VIL set,falseelse
-
isSequence
public boolean isSequence()
Description copied from class:TypeDescriptorReturns whether this descriptor represents a VIL sequence.- Specified by:
isSequencein classTypeDescriptor<CompoundInstance>- Returns:
trueif this is a VIL sequence,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<CompoundInstance>- Parameters:
object- the object to be checked- Returns:
trueif it is an instance,falseelse
-
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<CompoundInstance>- Parameters:
object- the object to be checked- Returns:
trueifobjecthas the same type,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<CompoundInstance>- 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
-
isInstantiator
public boolean isInstantiator()
Description copied from class:TypeDescriptorReturns whether this type is an instantiator.- Specified by:
isInstantiatorin classTypeDescriptor<CompoundInstance>- Returns:
trueif it is an instantiator,falseelse
-
setFields
public void setFields(CompoundTypeDescriptor.SlotDescriptor[] slots) throws VilException
Sets the fields of this descriptor, only if there have no fields been defined at all so far.- Parameters:
slots- the slots defining the fields- Throws:
VilException- in case that fields have been defined already
-
getSlot
public CompoundTypeDescriptor.SlotDescriptor getSlot(int index)
Returns the specified slot descriptor.- Parameters:
index- the 0-based index of the field to be returned- Returns:
- the specified field
- Throws:
java.lang.IndexOutOfBoundsException- ifindex < 0 || index>=getSlotCount()
-
getSlotCount
public int getSlotCount()
Returns the number of slots provided by this compound type.- Returns:
- the number of slots
-
getDeclaredField
public FieldDescriptor getDeclaredField(java.lang.String name)
Returns the directly declared field with namename.- Parameters:
name- the name of the field- Returns:
- the field descriptor or null
-
getField
public FieldDescriptor getField(java.lang.String name)
Description copied from class:TypeDescriptorReturns the field descriptor with the specified name.- Overrides:
getFieldin classTypeDescriptor<CompoundInstance>- Parameters:
name- the name of the field- Returns:
- the field descriptor (may be null if not found)
-
getSlot
public CompoundTypeDescriptor.SlotDescriptor getSlot(java.lang.String name)
Returns the slot descriptor with the specified name.- Parameters:
name- the name of the slot- Returns:
- the slot descriptor (may be null if not found)
-
getDeclaredSlot
public CompoundTypeDescriptor.SlotDescriptor getDeclaredSlot(java.lang.String name)
Returns the directly declared slot with namename.- Parameters:
name- the name of the slot- Returns:
- the slot descriptor or null
-
-