ComparableExt<Field>
CompoundField
, SimpleField
public abstract class Field extends java.lang.Object implements ComparableExt<Field>
We assume that unknown values are represented as well, but as default known one should be made.
Modifier and Type | Field | Description |
---|---|---|
static int |
KNOWN |
The field has a determined value assigned to it.
|
static int |
SEMIKNOWN |
Value of the field is not known, but it's not unknown either.
|
static int |
UNKNOWN |
Field's value hasn't been assigned.
|
Modifier and Type | Method | Description |
---|---|---|
abstract void |
copy(Field field) |
Takes all parameters from given field to itself.
|
abstract Field |
duplicate() |
Makes a new instance of a field.
|
boolean |
isGenerated() |
|
abstract boolean |
isSimilarTo(Field field) |
Tests if given field's type is similar to this one.
|
abstract int |
isUnknown() |
Checks whether this field's value is determined.
|
void |
setGenerated(boolean generated) |
|
abstract void |
setUnknown() |
Makes the simple field's value unknown.
|
compareTo
public static final int UNKNOWN
isUnknown()
method when one simple field
is known and when all simple fields are known in a compound field.public static final int SEMIKNOWN
public static final int KNOWN
public boolean isGenerated()
public void setGenerated(boolean generated)
generated
- The generated to set.public abstract int isUnknown()
UNKNOWN
doesn't mean that all components are known.
You have to check them as well.UNKNOWN
if the value is unknown,SEMIKNOWN
when only few simple fields are known (CompoundField only),KNOWN
otherwise (all simple fields have known values).public abstract void setUnknown()
(isUnknown() == UNKNOWN)When you assign any value to a field, it will be "known" then (or "semiknown" if it's compound field and some of its simple fields remain "unknown").
public abstract void copy(Field field)
isSimilarTo
method.
It is also possible to copy value from a field, which is an object of a subclass. For example, you can do this:
intField.copy(cardField);CardinalField contains only positive integer, which can be assigned to IntegerField. But you can't do it in reverse, because an IntegerField may contain a negative value. In general, you can copy from objects, which all values can be accepted here.
This method should throw InvalidTypeException
when
field's types are different and cannot be copied
field
- an object to copy class variables frompublic abstract Field duplicate()
public abstract boolean isSimilarTo(Field field)
true
only when
values from this field can be assigned to compared one and inversely as well.
This means that fields contain values from exactly the same domain.field
- reference to compared fieldtrue
if both fields are instances of the same class with the same domain