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
DerivedDatatype allows the user to create new data types based on existing types.
- Author:
- heiko beck
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate IDatatypeprivate Constraint[](package private) static final DelegatingTypeprivate List<IDerivedDatatypeListener> static final IDatatypeThis constant represents the common type of all derived datatypes.private DecisionVariableDeclaration -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateCreates the singleton instance forTYPE.DerivedDatatype(String name, IDatatype basisType, ModelElement parent) Constructor for the derived data type.DerivedDatatype(String name, IDatatype basisType, ModelElement parent, Constraint... constraints) Constructor for the derived data type. -
Method Summary
Modifier and TypeMethodDescriptionvoidaccept(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.Returns the basis type.getConstraint(int index) Returns a specific constraint.intReturns the number of constraints.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 final 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, isTypeMethods inherited from class net.ssehub.easy.varModel.model.ContainableModelElement
getNameSpace, getParent, getProject, getQualifiedName, getTopLevelParent, isTopLevel, setParentMethods inherited from class net.ssehub.easy.varModel.model.ModelElement
findAttribute, getComment, getName, getUniqueName, isTransparent, propagateAttribute, setComment, setName, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface net.ssehub.easy.varModel.model.datatypes.IDatatype
getName, getNameSpace, getQualifiedName, getUniqueName
-
Field Details
-
DTYPE
-
TYPE
This constant represents the common type of all derived datatypes. Each specific derived type is assignable to this type. -
typeDeclaration
-
constraints
-
basisType
-
listeners
-
-
Constructor Details
-
DerivedDatatype
private DerivedDatatype()Creates the singleton instance forTYPE. -
DerivedDatatype
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(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 Details
-
setConstraints
Changes the derivation constraints. [required as consequence of parent elements]- Parameters:
constraints- restricting constraints onbasisType, may be null
-
register
Registers a newIDerivedDatatypeListenerto this type.- Parameters:
listener- An instance of this type.
-
unregister
Unregisters an existingIDerivedDatatypeListenerto this type.- Parameters:
listener- An instance of this type.- Returns:
trueif this type contained the specified listener
-
getConstraintCount
public int getConstraintCount()Returns the number of constraints.- Returns:
- the number of constraints
-
getTypeDeclaration
This typeDeclaration is needed for the constraints.- Returns:
- typeDeclaration related to this datatype
-
getConstraint
Returns a specific constraint.- Parameters:
index- the index of the constraint- Returns:
- the specified constraint
- Throws:
IndexOutOfBoundsException- if0<index || index>getConstraintCount()
-
getBasisType
Returns the basis type.- Returns:
- the basis type
-
accept
Description copied from interface:IModelElementAccept method for the visitor.- Parameters:
visitor- The visitor, which should process this model element.
-
accept
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
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
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.
-