Class Enum
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.Enum
- All Implemented Interfaces:
IDatatype,IDatatypeVisitable,IModelElement
- Direct Known Subclasses:
OrderedEnum
Enumerations allow the definition of sets of named values.
- Author:
- heiko beck, Holger Eichelberger
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Operation(package private) static final DelegatingTypestatic final Operationstatic final Operationstatic final Operationprivate List<EnumLiteral> static final Operationstatic final Operationstatic final Operationstatic final IDatatypeThis constant represents the common type of all enums.static final Operation -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateEnum()Creates the singleton instance forTYPE.protectedEnum(String name, DelegatingType singleton, ModelElement parent) Constructor for an empty enum.protectedEnum(String name, ModelElement parent) Constructor for an empty enum.Enum(String name, ModelElement parent, String... literals) Constructor for the enum. -
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.private voidMethod to add an literal to the enumeration.booleanadd(EnumLiteral literal) Method to add an literal to the enumeration.Returns the enum literal with namename.getLiteral(int index) Returns the specified literal.getLiteralByOrdinal(int ordinal) Returns a literal by itsordinal.intReturns the number of literals.intgetLiteralIndex(EnumLiteral literal) Returns the index of the given literal.booleanhas(EnumLiteral literal) Returns whether this enum defines the specifiedliteral.booleanReturns whether this enum is ordered.Methods inherited from class net.ssehub.easy.varModel.model.datatypes.CustomDatatype
getGenericType, getGenericTypeCount, getOperation, getOperationCount, getType, getTypeClass, isAssignableFrom, 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 enums. Each specific enum type is assignable to this type. -
TYPE_OF
-
EQUALS
-
NOTEQUALS
-
NOTEQUALS_ALIAS
-
ASSIGNMENT
-
IS_DEFINED
-
IF_DEFINED
-
ORDINAL
-
literals
-
-
Constructor Details
-
Enum
private Enum()Creates the singleton instance forTYPE. -
Enum
Constructor for an empty enum.- Parameters:
name- Name of the enumparent- the object, in which this specific one is embedded
-
Enum
Constructor for an empty enum.- Parameters:
name- Name of the enumsingleton- the instance which knows the operationsparent- the object, in which this specific one is embedded
-
Enum
Constructor for the enum.- Parameters:
name- Name of the enumparent- the object, in which this specific one is embeddedliterals- literals to put into this Enum
-
-
Method Details
-
add
Method to add an literal to the enumeration.- Parameters:
literal- the literal to add
-
add
Method to add an literal to the enumeration.- Parameters:
literal- the literal to add- Returns:
trueif the operation was successful,false
-
has
Returns whether this enum defines the specifiedliteral.- Parameters:
literal- the literal to test for- Returns:
trueif it is defined,falseelse
-
get
Returns the enum literal with namename.- Parameters:
name- the name to search for- Returns:
- the literal or null
-
accept
Accept method for the visitor.- Parameters:
visitor- The visitor, which should process this model element.
-
getLiteralCount
public int getLiteralCount()Returns the number of literals.- Returns:
- the number of literals
-
getLiteral
Returns the specified literal.- Parameters:
index- the index of the literal to be returned- Returns:
- the specified literal
- Throws:
IndexOutOfBoundsException- ifindex<0 || index>=getLiteralCount()
-
getLiteralByOrdinal
Returns a literal by itsordinal.- Parameters:
ordinal- the ordinal of the enumeration literal- Returns:
- the literal or null if not found
-
getLiteralIndex
Returns the index of the given literal.- Parameters:
literal- the literal to search for- Returns:
- the index of the literal,
-1if not found
-
isOrdered
public boolean isOrdered()Returns whether this enum is ordered.- Returns:
trueif it is ordered,falseelse (defaultfalse)
-
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
-