ComparableExt<Field>
public class TrapezoidalField extends CompoundField
All fields must be of the same type, so there is one domain for trapezoidal field. When you create this interval all simple fields' value must be in non-decreasing order. Later you can change them indepednently, but you have to check an order by yourself. Remember that domain cannot be change, only values can.
Constructor | Description |
---|---|
TrapezoidalField(SimpleField newValues) |
Creates new trapezoidal value and stores given field as all fields.
|
TrapezoidalField(SimpleField bottomLeft,
SimpleField topLeft,
SimpleField topRight,
SimpleField bottomRight) |
Creates new trapezoidal value and stores given simple fields.
|
Modifier and Type | Method | Description |
---|---|---|
boolean |
checkConstraints() |
Checks if simple fields' type and order is correct.
|
java.lang.Integer |
compareTo(Field object) |
Compares other field to this field.
|
void |
copy(Field field) |
It makes a copy of class variables taking their values from given interval.
|
Field |
duplicate() |
Makes a new instance of a field.
|
SimpleField |
getBottomLeft() |
Gives a reference to bottom left field.
|
SimpleField |
getBottomRight() |
Gives a reference to bottom right field.
|
java.lang.Class<? extends SimpleField> |
getInnerType() |
Gives a type of fields which are stored inside the trapeziodal field.
|
SimpleField |
getTopLeft() |
Gives a reference to top left field.
|
SimpleField |
getTopRight() |
Gives a reference to top right field.
|
boolean |
isSimilarTo(Field field) |
Tests if given field's type is similar to this one.
|
int |
isUnknown() |
Test if trapezoidal field has determined value.
|
void |
setUnknown() |
Assigns an unknown value to this field.
|
java.lang.String |
toString() |
Returns a
String which represents value of this field. |
isGenerated, setGenerated
public TrapezoidalField(SimpleField newValues)
newValues
- one simple field element to store in intervaljava.lang.NullPointerException
- if given field is nullpublic TrapezoidalField(SimpleField bottomLeft, SimpleField topLeft, SimpleField topRight, SimpleField bottomRight)
bottomLeft
- outer left boundarytopLeft
- inner left onetopRight
- inner right onebottomRight
- outer right oneConsistencyException
- when there is wrong values' orderInvalidTypeException
- if simple fields' type is differentjava.lang.NullPointerException
- if any of given fields is nullcheckConstraints()
public boolean checkConstraints()
checkConstraints
in class CompoundField
false
when there is known value less than its nearest left known neighbour,
true
otherwisepublic SimpleField getBottomLeft()
public SimpleField getTopLeft()
public SimpleField getTopRight()
public SimpleField getBottomRight()
public void copy(Field field)
copy
in class Field
field
- trapezoidal interval with simple fields of the same typeInvalidTypeException
- when given field is not TrapezoidalField
or simple fields cannot be copied (because of different type)java.lang.NullPointerException
- if given field is nullpublic Field duplicate()
Field
public java.lang.Class<? extends SimpleField> getInnerType()
public boolean isSimilarTo(Field field)
isSimilarTo
in class Field
field
- trapezoidal field to check similarity with this fieldtrue
if both fields are trapezoidal intervals with simple fields
of the same typejava.lang.NullPointerException
- when given field is nullpublic java.lang.String toString()
String
which represents value of this field.
If trapezoidal interval is known, the result is set of simple fields' values separated by comma
and enclosed in brackets. In particular some values may be known and the others unknown.
When all are unknown, whole trapezoidal field is unknown and the result is question mark.toString
in class java.lang.Object
public int isUnknown()
public void setUnknown()
setUnknown
in class Field
public java.lang.Integer compareTo(Field object)
object
- other field to compare with