ComparableExt<Field>public class PairField extends CompoundField
IntervalField, used to store pairs of simple values.
Main goal of this class is to offer means of storing pairs of simple values in PCT.
Pair of IntegerField or CardinalField values may indicate comparison of which two examples consists given row, while
pair of EnumField or StringField values may be used to store a pair of nominal (ordinal)
values for two examples.
Preference type for PairField attribute, which arose from some SimpleField attribute,
should be the same as for that SimpleField attribute.| Modifier and Type | Field | Description |
|---|---|---|
static int |
ANOTHER_PAIR_IS_EQUAL |
Constant used in
checkDominance method to indicate that this and another pair are equal
(first element from this pair is equal to first element from another pair and
second element from this pair is equal to second element from another pair) |
static int |
ANOTHER_PAIR_IS_INCOMPARABLE |
Constant used in
checkDominance method to indicate that this and another pair are incomparable |
static int |
ANOTHER_PAIR_IS_STRICTLY_DOMINATED |
Constant used in
checkDominance method to indicate that this pair strictly dominates another one |
static int |
ANOTHER_PAIR_STRICTLY_DOMINATES |
Constant used in
checkDominance method to indicate that another pair strictly dominates this one |
static int |
CLASSIC_ORDINAL_DOMINANCE_CHECK_METHOD |
Possible value of dominance check method used when "classic" approach should be used.
|
static int |
DEFAULT_ORDINAL_DOMINANCE_CHECK_METHOD |
Default dominance check method.
|
static int |
STRICT_ORDINAL_DOMINANCE_CHECK_METHOD |
Possible value of dominance check method used when "strict" approach should be used.
|
| Constructor | Description |
|---|---|
PairField(SimpleField first,
SimpleField second) |
Makes new pair with given two elements.
|
| Modifier and Type | Method | Description |
|---|---|---|
boolean |
checkConstraints() |
Checks if pair is correct, that is if both elements are of the same type.
|
int |
checkDominance(PairField anotherPair,
int preferenceType) |
Checks if this pair strictly dominates another one, another pair strictly dominates this one,
pairs are equal or incomparable.
|
java.lang.Integer |
compareTo(Field object) |
Compares other object to this object.
|
void |
copy(Field field) |
Makes and saves a copy of given field.
|
Field |
duplicate() |
Returns a duplicate of this field, containing the same elements.
|
boolean |
equals(java.lang.Object object) |
Checks if given object is also a pair of simple values equal to this one
|
static int |
getDominanceCheckMethod() |
Gets current dominance check method.
|
SimpleField |
getFirstElement() |
Reads the first element in the pair.
|
java.lang.Class<? extends SimpleField> |
getInnerType() |
Gets type of fields which are held inside this pair.
|
SimpleField |
getSecondElement() |
Reads the second element in the pair.
|
int |
hashCode() |
Gets hash code of this object.
|
boolean |
isSimilarTo(Field field) |
Tests if given field's type is similar to this one.
|
int |
isUnknown() |
Tests if pair's elements are determined.
|
static void |
resetDominanceCheckMethod() |
Restores default dominance check method
|
static void |
setDominanceCheckMethod(int dominanceCheckMethod) |
Sets dominance check method used in
checkDominance member function. |
void |
setUnknown() |
Makes pair unknown.
|
java.lang.String |
toString() |
Returns a
String which represents value of this field. |
java.lang.String |
toStringWithIncrementation() |
Returns a
String which represents value of this field. |
isGenerated, setGeneratedpublic static final int ANOTHER_PAIR_IS_STRICTLY_DOMINATED
checkDominance method to indicate that this pair strictly dominates another onepublic static final int ANOTHER_PAIR_STRICTLY_DOMINATES
checkDominance method to indicate that another pair strictly dominates this onepublic static final int ANOTHER_PAIR_IS_EQUAL
checkDominance method to indicate that this and another pair are equal
(first element from this pair is equal to first element from another pair and
second element from this pair is equal to second element from another pair)public static final int ANOTHER_PAIR_IS_INCOMPARABLE
checkDominance method to indicate that this and another pair are incomparablepublic static final int STRICT_ORDINAL_DOMINANCE_CHECK_METHOD
checkDominance method for more details.public static final int CLASSIC_ORDINAL_DOMINANCE_CHECK_METHOD
checkDominance method for more details.public static final int DEFAULT_ORDINAL_DOMINANCE_CHECK_METHOD
CLASSIC_ORDINAL_DOMINANCE_CHECK_METHOD value.public PairField(SimpleField first, SimpleField second)
getFirstElement or getSecondElement methods.
Type of both elements must be the same.first - simple field stored as first pair elementsecond - simple field stored as second pair elementInvalidTypeException - when types of simple fields are different (not similar)java.lang.NullPointerException - if any simple field is nullpublic static void setDominanceCheckMethod(int dominanceCheckMethod)
checkDominance member function.
Checks if given value is equal to: STRICT_ORDINAL_DOMINANCE_CHECK_METHOD or CLASSIC_ORDINAL_DOMINANCE_CHECK_METHOD.
SIC! By modifying class variable this method affects all subsequent calls to checkDominance method.
To restore default dominance check method at any time, call resetDominanceCheckMethod method.dominanceCheckMethod - dominance check methodInvalidValueException - when dominanceCheckMethod is not
STRICT_ORDINAL_DOMINANCE_CHECK_METHOD nor CLASSIC_ORDINAL_DOMINANCE_CHECK_METHODpublic static void resetDominanceCheckMethod()
public static int getDominanceCheckMethod()
STRICT_ORDINAL_DOMINANCE_CHECK_METHOD or
CLASSIC_ORDINAL_DOMINANCE_CHECK_METHOD.public boolean checkConstraints()
checkConstraints in class CompoundFieldtrue when types of both elements are the same,false otherwisepublic SimpleField getFirstElement()
public SimpleField getSecondElement()
public void copy(Field field)
copy in class Fieldfield - object which is pair with simple fields of the same type as this pairInvalidTypeException - when field is not PairField or if simple fields cannot be copiedjava.lang.NullPointerException - if given field is nullpublic Field duplicate()
public java.lang.Class<? extends SimpleField> getInnerType()
public boolean isSimilarTo(Field field)
isSimilarTo in class Fieldfield - compared field (pair)true if both fields are pairs with similar simple fields,false otherwisejava.lang.NullPointerException - when given field is nullpublic java.lang.String toString()
String which represents value of this field.
If field is unknown, then ? is returned.toString in class java.lang.Objectpublic java.lang.String toStringWithIncrementation()
String which represents value of this field.
If field is unknown, then ? is returned.
Increments both pair's element if they are of type IntgerField or CardinalField.public int isUnknown()
public void setUnknown()
setUnknown in class Fieldpublic int checkDominance(PairField anotherPair, int preferenceType)
SimpleField.compareTo method.
If preference type is Attribute.NONE, then it is only checked if pairs are equal or incomparable.dominanceCheckMethod field description for details.anotherPair - another pair to compare with this onepreferenceType - Type of preference used to compare values of pairs' inner simple fields. Can be one
of Attribute.GAIN, Attribute.COST or Attribute.NONE.ANOTHER_PAIR_IS_STRICTLY_DOMINATED if this pair strictly dominates another one,
ANOTHER_PAIR_STRICTLY_DOMINATES if another pair strictly dominates this one,
ANOTHER_PAIR_IS_EQUAL if this and another pair are equal,
ANOTHER_PAIR_IS_INCOMPARABLE if this and another pair are incomparablejava.lang.NullPointerException - when checked another pair is nullInvalidTypeException - when inner type of checked another pair is different than inner type of this pairInvalidValueException - when preference type is none of Attribute.NONE,
Attribute.GAIN and Attribute.COSTpublic int hashCode()
hashCode in class java.lang.Objectpublic boolean equals(java.lang.Object object)
equals in class java.lang.Objectobject - object to checktrue if given object is also a pair of simple values equal to this one, false otherwisepublic java.lang.Integer compareTo(Field object)
object - other object to compare with