Class IvmlTypeDescriptor

    • Constructor Detail

      • 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 for
        ivmlType - the IVML type to create the descriptor for
        resolver - 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 for
        ivmlType - the IVML type to resolve for
        declaredAttributes - 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 process
        operations - the operations (may be modified as a side effect)
        fields - the actually known fields of ivmlType (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 process
        operations - 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 process
        conversions - 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 container
        registry - the actual type registry
        fields - 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: IMetaType
        Returns the base type (in case of IVML derived types).
        Specified by:
        getBaseType in interface IMetaType
        Returns:
        the base type or null
      • 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<DecisionVariable>
        Parameters:
        desc - the descriptor to be tested
        Returns:
        true if both descriptors are assignment compatible, false else
      • isSet

        public boolean isSet()
        Description copied from class: TypeDescriptor
        Returns whether this descriptor represents a VIL set.
        Overrides:
        isSet in class AbstractIvmlTypeDescriptor
        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.
        Overrides:
        isSequence in class AbstractIvmlTypeDescriptor
        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<DecisionVariable>
        Parameters:
        object - the object to be checked
        Returns:
        true if it is an instance, false else
      • getDatatype

        private IDatatype getDatatype​(java.lang.Object object)
        Returns the datatype for object.
        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: TypeDescriptor
        Returns whether the given object of of the type of this descriptor.
        Specified by:
        isSameType in class TypeDescriptor<DecisionVariable>
        Parameters:
        object - the object to be checked
        Returns:
        true if object has the same type, false else
      • 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.
        Specified by:
        isPlaceholder in interface IMetaType
        Returns:
        true if this type is a placeholder, 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<DecisionVariable>
        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
      • isInternal

        public boolean isInternal()
        Description copied from interface: IMetaType
        Returns whether this type is internal and shall not be visible to the user.
        Specified by:
        isInternal in interface IMetaType
        Returns:
        true if this type is internal, 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.
        Specified by:
        checkConversion in interface IMetaType
        Parameters:
        param - the original parameter value
        conversion - the conversion function
        Returns:
        true if ok, false else