Class 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
    • 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 with
        name - the name of the alias type
        type - 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: IMetaType
        Returns whether this type is the same or a super class of type.
        Parameters:
        type - the descriptor to be tested
        Returns:
        true if both types are assignment compatible, false else
      • isBasicType

        public boolean isBasicType()
        Description copied from interface: IMetaType
        Returns whether this instance represents a basic type.
        Returns:
        true if this instance represents a basic type, false else
      • getTypeRegistry

        public TypeRegistry getTypeRegistry()
        Description copied from interface: IMetaType
        Returns the type registry this type was registered by.
        Returns:
        the type registry
      • isPlaceholder

        public boolean isPlaceholder()
        Description copied from interface: IMetaType
        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.
        Returns:
        true if this type is a placeholder, false else
      • isActualTypeOf

        public boolean isActualTypeOf​(IMetaType type)
        Description copied from interface: IMetaType
        Returns whether this type can act as an actual type of type.
        Parameters:
        type - the type to be checked
        Returns:
        true if this type can act as an actual type of type, false else
        See Also:
        IActualTypeProvider
      • getBaseType

        public IMetaType getBaseType()
        Description copied from interface: IMetaType
        Returns the base type (in case of IVML derived types).
        Returns:
        the base type or null
      • getSuperType

        public IMetaType getSuperType()
        Description copied from interface: IMetaType
        Returns 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: IMetaType
        Returns whether this type is internal and shall not be visible to the user.
        Returns:
        true if this type is internal, false else
      • getTypeClass

        public java.lang.Class<T> getTypeClass()
        Description copied from class: TypeDescriptor
        Returns the class of the described VIL type. Please use this method sparingly as the required functionality is provided by this class.
        Specified by:
        getTypeClass in class TypeDescriptor<T>
        Returns:
        the class
      • create

        public T create​(java.lang.Object... params)
                 throws VilException
        Description copied from class: TypeDescriptor
        Creates an instance of the type according to the given parameters.
        Specified by:
        create in class TypeDescriptor<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: TypeDescriptor
        Returns whether this descriptor is the same or a super class of desc.
        Specified by:
        isAssignableFrom in class TypeDescriptor<T>
        Parameters:
        desc - the descriptor to be tested
        Returns:
        true if both descriptors are assignment compatible, false else
      • isIterator

        public boolean isIterator()
        Description copied from class: TypeDescriptor
        Returns whether this descriptor represents an iterator.
        Specified by:
        isIterator in class TypeDescriptor<T>
        Returns:
        true if this is an iterator, false else
      • isMap

        public boolean isMap()
        Description copied from class: TypeDescriptor
        Returns whether this descriptor represents a VIL map.
        Specified by:
        isMap in class TypeDescriptor<T>
        Returns:
        true if this is a VIL map, false else
      • isCollection

        public boolean isCollection()
        Description copied from class: TypeDescriptor
        Returns whether this descriptor represents a VIL collection, i.e., set, sequence or collection.
        Specified by:
        isCollection in class TypeDescriptor<T>
        Returns:
        true if this is a VIL collection, false else
      • isSet

        public boolean isSet()
        Description copied from class: TypeDescriptor
        Returns whether this descriptor represents a VIL set.
        Specified by:
        isSet in class TypeDescriptor<T>
        Returns:
        true if this is a VIL set, false else
      • isSequence

        public boolean isSequence()
        Description copied from class: TypeDescriptor
        Returns whether this descriptor represents a VIL sequence.
        Specified by:
        isSequence in class TypeDescriptor<T>
        Returns:
        true if this is a VIL sequence, false else
      • isInstance

        public boolean isInstance​(java.lang.Object object)
        Description copied from class: TypeDescriptor
        Returns whether the given object is an instance of this descriptor.
        Specified by:
        isInstance in class TypeDescriptor<T>
        Parameters:
        object - the object to be checked
        Returns:
        true if it is an instance, false else
      • isSameType

        public boolean isSameType​(java.lang.Object object)
        Description copied from class: TypeDescriptor
        Returns whether the given object of of the type of this descriptor.
        Specified by:
        isSameType in class TypeDescriptor<T>
        Parameters:
        object - the object to be checked
        Returns:
        true if object has the same type, false else
      • addPlaceholderOperation

        public OperationDescriptor addPlaceholderOperation​(java.lang.String name,
                                                           int parameterCount,
                                                           boolean acceptsNamedParameters)
        Description copied from class: TypeDescriptor
        Adds a placeholder operation, i.e., in case that the original operation cannot be resolved but the script shall remain executable.
        Specified by:
        addPlaceholderOperation in interface IMetaType
        Specified by:
        addPlaceholderOperation in class TypeDescriptor<T>
        Parameters:
        name - the name of the operation
        parameterCount - the number of parameters of the operation
        acceptsNamedParameters - 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: TypeDescriptor
        Returns whether this type is an instantiator.
        Specified by:
        isInstantiator in class TypeDescriptor<T>
        Returns:
        true if it is an instantiator, false else
      • checkConversion

        public boolean checkConversion​(IMetaType param,
                                       IMetaOperation conversion)
        Description copied from interface: IMetaType
        Checks a conversion from this type to param via the given conversion.
        Parameters:
        param - the original parameter value
        conversion - the conversion function
        Returns:
        true if ok, false else
      • unalias

        static IMetaType unalias​(IMetaType type)
        Unalisases type.
        Parameters:
        type - the type
        Returns:
        the unalised type
      • unalias

        static TypeDescriptor<?> unalias​(TypeDescriptor<?> type)
        Unalisases type.
        Parameters:
        type - the type
        Returns:
        the unalised type