ComparableExt<Field>public class EnumField extends SimpleField
If you want to store an element of a domain you should create the domain first. It is very important that you are only able to change value of EnumField, but not a domain. So all values assigned to this field must be members of one domain, which has to be created first. It is possible to have an empty domain, but when you want to create an enum field, you have to add one element to the domain before.
| Constructor | Description |
|---|---|
EnumField(int index,
EnumDomain domain) |
Creates a new
EnumField with a reference to the element having given index in the domain. |
EnumField(java.lang.String name,
EnumDomain domain) |
Creates a new EnumField with a reference to an element having the specified name in the domain.
|
| Modifier and Type | Method | Description |
|---|---|---|
int |
compareTo(SimpleField arg0) |
Compares two enum fields.
|
void |
copy(Field field) |
It makes a copy of class variables.
|
Field |
duplicate() |
Makes a new instance of a field.
|
boolean |
equals(java.lang.Object arg0) |
Checks equivalence of two objects
|
EnumDomain |
getDomain() |
Gets the domain of this element.
|
int |
getIndex() |
Gives an index of this element in the domain.
|
java.lang.String |
getName() |
Gets the name of this element in the domain.
|
int |
hashCode() |
Provides hashcode of a given
EnumField value. |
boolean |
isSimilarTo(Field field) |
Tests if given field's type and domain are the same as this one.
|
void |
set(int valueIndex) |
Changes the value by looking for a reference to an element with given index.
|
void |
set(java.lang.String name) |
Changes the value by looking for a reference to an element with given name.
|
java.lang.String |
toString() |
Returns a
String which represents the value of this field. |
isGenerated, setGeneratedcompareTo, isUnknown, setUnknownpublic EnumField(int index,
EnumDomain domain)
EnumField with a reference to the element having given index in the domain.
Remember that the domain cannot be changed in the future (except for adding new elements).
All elements stored in this field must always belong to the same domain.index - position of the element in the domaindomain - reference to the domain, in which the element is going to be searched forInvalidValueException - when the domain doesn't contain an element of such indexjava.lang.NullPointerException - when the domain is nullpublic EnumField(java.lang.String name,
EnumDomain domain)
name - value of the element in the domaindomain - reference to the domain, in which the element is going to be searched forInvalidValueException - when there is no such name in the domainjava.lang.NullPointerException - when the name or the domain is nullpublic void copy(Field field)
value and unknown.
Given field must be of the same type, which means that it represents a
value from exactly the same domain.copy in class Fieldfield - any object which is an instance of EnumField refering to the same domainInvalidTypeException - when the field is not EnumField or the domain is differentjava.lang.NullPointerException - if given field is nullpublic EnumDomain getDomain()
public int getIndex()
UnknownValueException - if the value is unknownpublic java.lang.String getName()
UnknownValueException - if the value is unknownpublic void set(int valueIndex)
isUnknown() is KNOWN).valueIndex - position in the domainInvalidValueException - if the index is out of domainpublic void set(java.lang.String name)
isUnknown() is KNOWN).name - string to be stored in this elementInvalidValueException - when the name hasn't been found in the domainjava.lang.NullPointerException - if name is nullpublic Field duplicate()
Fieldpublic int compareTo(SimpleField arg0)
arg0 - object to be compared to this enum field (should be also enum field)java.lang.ClassCastException - if given object is not EnumField or the
enum domain of the compared enum field is differentjava.lang.NullPointerException - when given object is nullUnknownValueException - when field's value is unknownpublic boolean isSimilarTo(Field field)
EnumField). They also must belong to the same domain. If the fields meet these
two conditions, the result is true.
Domains are first compared by references, than (only if needed) it is checked if they are the same.isSimilarTo in class SimpleFieldfield - field to be compared to this enum fieldtrue if this and given field are similar, false otherwisejava.lang.NullPointerException - when given field is nullpublic boolean equals(java.lang.Object arg0)
equals in class java.lang.Objectarg0 - object to be compared with this enum fieldjava.lang.NullPointerException - when given object is nullpublic int hashCode()
EnumField value.hashCode in class java.lang.ObjectEnumField valuepublic java.lang.String toString()
String which represents the value of this field.
If the value is known, the result is simply the name of the element.toString in class java.lang.Object