Class DerivedDatatype

All Implemented Interfaces:
IDatatype, IDatatypeVisitable, IModelElement

public class DerivedDatatype extends CustomDatatype
DerivedDatatype allows the user to create new data types based on existing types.
Author:
heiko beck
  • Field Details

  • Constructor Details

    • DerivedDatatype

      private DerivedDatatype()
      Creates the singleton instance for TYPE.
    • DerivedDatatype

      public DerivedDatatype(String name, IDatatype basisType, ModelElement parent)
      Constructor for the derived data type.
      Parameters:
      name - the name of the derived data type
      basisType - the type the this datatype is derived from
      parent - the object, in which this specific one is embedded
    • DerivedDatatype

      public DerivedDatatype(String name, IDatatype basisType, ModelElement parent, Constraint... constraints)
      Constructor for the derived data type.
      Parameters:
      name - the name of the derived data type
      basisType - the type the this datatype is derived from
      parent - the object, in which this specific one is embedded
      constraints - restricting constraints on basisType, may be null
  • Method Details

    • setConstraints

      public void setConstraints(Constraint[] constraints)
      Changes the derivation constraints. [required as consequence of parent elements]
      Parameters:
      constraints - restricting constraints on basisType, may be null
    • register

      public void register(IDerivedDatatypeListener listener)
      Registers a new IDerivedDatatypeListener to this type.
      Parameters:
      listener - An instance of this type.
    • unregister

      public boolean unregister(IDerivedDatatypeListener listener)
      Unregisters an existing IDerivedDatatypeListener to this type.
      Parameters:
      listener - An instance of this type.
      Returns:
      true if this type contained the specified listener
    • getConstraintCount

      public int getConstraintCount()
      Returns the number of constraints.
      Returns:
      the number of constraints
    • getTypeDeclaration

      public DecisionVariableDeclaration getTypeDeclaration()
      This typeDeclaration is needed for the constraints.
      Returns:
      typeDeclaration related to this datatype
    • getConstraint

      public Constraint getConstraint(int index)
      Returns a specific constraint.
      Parameters:
      index - the index of the constraint
      Returns:
      the specified constraint
      Throws:
      IndexOutOfBoundsException - if 0<index || index>getConstraintCount()
    • getBasisType

      public IDatatype getBasisType()
      Returns the basis type.
      Returns:
      the basis type
    • accept

      public void accept(IModelVisitor visitor)
      Description copied from interface: IModelElement
      Accept method for the visitor.
      Parameters:
      visitor - The visitor, which should process this model element.
    • accept

      public void accept(IDatatypeVisitor visitor)
      Description copied from interface: IDatatypeVisitable
      Accepts a specialized visitor for creating a textual representation of the identity of this type.
      Specified by:
      accept in interface IDatatypeVisitable
      Overrides:
      accept in class ContainableModelElement
      Parameters:
      visitor - the visitor to accept
    • isAssignableFrom

      public boolean isAssignableFrom(IDatatype type)
      Description copied from class: CustomDatatype
      Determines if the data type represented by this object is either the same as, or is a supertype of type.
      Specified by:
      isAssignableFrom in interface IDatatype
      Overrides:
      isAssignableFrom in class CustomDatatype
      Parameters:
      type - the type being checked
      Returns:
      true if this type is either the same or a supertype of type, true else
    • resolveToBasis

      public static final IDatatype resolveToBasis(IDatatype type)
      Resolves the given type to its innermost basis datatype. We cannot do this automatically, as otherwise the tests for assignable types, e.g. to Compounds, would fail.
      Parameters:
      type - the type to be resolved
      Returns:
      the innermost basis datatype, type if type is not a DerivedDatatype.