Class AliasTypeDescriptor<T>
- java.lang.Object
-
- net.ssehub.easy.instantiation.core.model.vilTypes.TypeDescriptor<T>
-
- net.ssehub.easy.instantiation.core.model.vilTypes.AliasTypeDescriptor<T>
-
- Type Parameters:
T- the specific VilType or Artifact
- All Implemented Interfaces:
IMetaType
class AliasTypeDescriptor<T> extends TypeDescriptor<T>
Defines a delegating alias type.- Author:
- Holger Eichelberger
-
-
Field Summary
Fields Modifier and Type Field Description private TypeRegistryregistryprivate TypeDescriptor<T>type-
Fields inherited from class net.ssehub.easy.instantiation.core.model.vilTypes.TypeDescriptor
EMPTY
-
-
Constructor Summary
Constructors Constructor Description AliasTypeDescriptor(TypeRegistry registry, java.lang.String name, TypeDescriptor<T> type)Creates an alias type descriptor.
-
Method Summary
All Methods Static 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.Tcreate(java.lang.Object... params)Creates an instance of the type according to the given parameters.(package private) TypeDescriptor<?>getAliasedType()Returns the aliased type.IMetaTypegetBaseType()Returns the base type (in case of IVML derived types).IMetaTypegetSuperType()Returns the type this type is refined from.java.lang.Class<T>getTypeClass()Returns the class of the described VIL type.TypeRegistrygetTypeRegistry()Returns the type registry this type was registered by.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.private static <T> java.util.Collection<T>toCollection(java.lang.Iterable<T> src)Turns an iterable into a collection.(package private) static IMetaTypeunalias(IMetaType type)Unalisasestype.(package private) static TypeDescriptor<?>unalias(TypeDescriptor<?> type)Unalisasestype.-
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, getField, getFieldCount, getFields, getGenericParameter, getGenericParameterCount, getGenericParameterType, getName, getOperation, getOperations, getOperationsCount, getQualifiedName, getVilName, isFieldsNull, isInitialized, isNameSet, isSame, setConversions, setFields, setFields, setName, setOperations, toString
-
-
-
-
Field Detail
-
type
private TypeDescriptor<T> type
-
registry
private TypeRegistry registry
-
-
Constructor Detail
-
AliasTypeDescriptor
AliasTypeDescriptor(TypeRegistry registry, java.lang.String name, TypeDescriptor<T> type) throws VilException
Creates an alias type descriptor.- Parameters:
registry- the type registry this type is registered withname- the name of the alias typetype- the represented (aliased) type- Throws:
VilException- if creating the type fails
-
-
Method Detail
-
toCollection
private static <T> java.util.Collection<T> toCollection(java.lang.Iterable<T> src)
Turns an iterable into a collection.- Type Parameters:
T- the element type- Parameters:
src- the source iterable- Returns:
- the collection containing all elements from
src
-
getAliasedType
TypeDescriptor<?> getAliasedType()
Returns the aliased type.- Returns:
- the aliased type
-
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
-
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
-
getTypeClass
public java.lang.Class<T> 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<T>- Returns:
- the class
-
canBeInstantiated
public boolean canBeInstantiated()
Description copied from class:TypeDescriptorReturns whetherTypeDescriptor.create(Object...)will return an instance.- Specified by:
canBeInstantiatedin classTypeDescriptor<T>- Returns:
trueif this type can be instantiated from VIL/VTL,falseelse
-
create
public T 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<T>- 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<T>- Parameters:
desc- the descriptor to be tested- Returns:
trueif both descriptors are assignment compatible,falseelse
-
isIterator
public boolean isIterator()
Description copied from class:TypeDescriptorReturns whether this descriptor represents an iterator.- Specified by:
isIteratorin classTypeDescriptor<T>- Returns:
trueif this is an iterator,falseelse
-
isMap
public boolean isMap()
Description copied from class:TypeDescriptorReturns whether this descriptor represents a VIL map.- Specified by:
isMapin classTypeDescriptor<T>- Returns:
trueif this is a VIL map,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<T>- 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<T>- 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<T>- 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<T>- 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<T>- 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<T>- 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<T>- 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.- Parameters:
param- the original parameter valueconversion- the conversion function- Returns:
trueif ok,falseelse
-
unalias
static IMetaType unalias(IMetaType type)
Unalisasestype.- Parameters:
type- the type- Returns:
- the unalised type
-
unalias
static TypeDescriptor<?> unalias(TypeDescriptor<?> type)
Unalisasestype.- Parameters:
type- the type- Returns:
- the unalised type
-
-