Class DerivedDatatype
- java.lang.Object
-
- net.ssehub.easy.varModel.model.ModelElement
-
- net.ssehub.easy.varModel.model.ContainableModelElement
-
- net.ssehub.easy.varModel.model.datatypes.CustomDatatype
-
- net.ssehub.easy.varModel.model.datatypes.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 Summary
Fields Modifier and Type Field Description private IDatatypebasisTypeprivate Constraint[]constraints(package private) static DelegatingTypeDTYPEprivate java.util.List<IDerivedDatatypeListener>listenersstatic IDatatypeTYPEThis constant represents the common type of all derived datatypes.private DecisionVariableDeclarationtypeDeclaration
-
Constructor Summary
Constructors Modifier Constructor Description privateDerivedDatatype()Creates the singleton instance forTYPE.DerivedDatatype(java.lang.String name, IDatatype basisType, ModelElement parent)Constructor for the derived data type.DerivedDatatype(java.lang.String name, IDatatype basisType, ModelElement parent, Constraint... constraints)Constructor for the derived data type.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaccept(IDatatypeVisitor visitor)Accepts a specialized visitor for creating a textual representation of the identity of this type.voidaccept(IModelVisitor visitor)Accept method for the visitor.IDatatypegetBasisType()Returns the basis type.ConstraintgetConstraint(int index)Returns a specific constraint.intgetConstraintCount()Returns the number of constraints.DecisionVariableDeclarationgetTypeDeclaration()This typeDeclaration is needed for the constraints.booleanisAssignableFrom(IDatatype type)Determines if the data type represented by this object is either the same as, or is a supertype oftype.voidregister(IDerivedDatatypeListener listener)Registers a newIDerivedDatatypeListenerto this type.static IDatatyperesolveToBasis(IDatatype type)Resolves the given type to its innermost basis datatype.voidsetConstraints(Constraint[] constraints)Changes the derivation constraints.booleanunregister(IDerivedDatatypeListener listener)Unregisters an existingIDerivedDatatypeListenerto this type.-
Methods inherited from class net.ssehub.easy.varModel.model.datatypes.CustomDatatype
getGenericType, getGenericTypeCount, getOperation, getOperationCount, getType, getTypeClass, isPrimitive, isPseudoType, isType
-
Methods inherited from class net.ssehub.easy.varModel.model.ContainableModelElement
getNameSpace, getParent, getProject, getQualifiedName, getTopLevelParent, isTopLevel, setParent
-
Methods inherited from class net.ssehub.easy.varModel.model.ModelElement
findAttribute, getComment, getName, getUniqueName, isTransparent, propagateAttribute, setComment, setName, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface net.ssehub.easy.varModel.model.datatypes.IDatatype
getName, getNameSpace, getQualifiedName, getUniqueName
-
-
-
-
Field Detail
-
DTYPE
static final DelegatingType DTYPE
-
TYPE
public static final IDatatype TYPE
This constant represents the common type of all derived datatypes. Each specific derived type is assignable to this type.
-
typeDeclaration
private DecisionVariableDeclaration typeDeclaration
-
constraints
private Constraint[] constraints
-
basisType
private IDatatype basisType
-
listeners
private java.util.List<IDerivedDatatypeListener> listeners
-
-
Constructor Detail
-
DerivedDatatype
private DerivedDatatype()
Creates the singleton instance forTYPE.
-
DerivedDatatype
public DerivedDatatype(java.lang.String name, IDatatype basisType, ModelElement parent)Constructor for the derived data type.- Parameters:
name- the name of the derived data typebasisType- the type the this datatype is derived fromparent- the object, in which this specific one is embedded
-
DerivedDatatype
public DerivedDatatype(java.lang.String name, IDatatype basisType, ModelElement parent, Constraint... constraints)Constructor for the derived data type.- Parameters:
name- the name of the derived data typebasisType- the type the this datatype is derived fromparent- the object, in which this specific one is embeddedconstraints- restricting constraints onbasisType, may be null
-
-
Method Detail
-
setConstraints
public void setConstraints(Constraint[] constraints)
Changes the derivation constraints. [required as consequence of parent elements]- Parameters:
constraints- restricting constraints onbasisType, may be null
-
register
public void register(IDerivedDatatypeListener listener)
Registers a newIDerivedDatatypeListenerto this type.- Parameters:
listener- An instance of this type.
-
unregister
public boolean unregister(IDerivedDatatypeListener listener)
Unregisters an existingIDerivedDatatypeListenerto 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:
java.lang.IndexOutOfBoundsException- if0<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:IModelElementAccept method for the visitor.- Parameters:
visitor- The visitor, which should process this model element.
-
accept
public void accept(IDatatypeVisitor visitor)
Description copied from interface:IDatatypeVisitableAccepts a specialized visitor for creating a textual representation of the identity of this type.- Specified by:
acceptin interfaceIDatatypeVisitable- Overrides:
acceptin classContainableModelElement- Parameters:
visitor- the visitor to accept
-
isAssignableFrom
public boolean isAssignableFrom(IDatatype type)
Description copied from class:CustomDatatypeDetermines if the data type represented by this object is either the same as, or is a supertype oftype.- Specified by:
isAssignableFromin interfaceIDatatype- Overrides:
isAssignableFromin classCustomDatatype- Parameters:
type- the type being checked- Returns:
trueif this type is either the same or a supertype oftype,trueelse
-
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,
typeiftypeis not aDerivedDatatype.
-
-