ComparableExt<Field>public class SimilarityField extends CompoundField
PairField, used to store (similarity, reference value) pairs.
Main goal of this class is to offer means of storing pairs of simple values in similarity table.| 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
(similarity value from this pair is equal to similarity value from another pair and
reference value from this pair is equal to reference value 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 |
numberOfSimilarityDecimalPlaces |
Number of decimal places in text representation of this field, concerning only floating-point similarity
(i.e. similarity of type
FloatField.) |
| Constructor | Description |
|---|---|
SimilarityField(SimpleField similarity,
SimpleField referenceValue) |
Makes new (similarity, reference value) pair with given two elements.
|
| Modifier and Type | Method | Description |
|---|---|---|
boolean |
checkConstraints() |
Checks whether the compound field has correct values stored as simple fields.
|
int |
checkDominance(SimilarityField anotherPair,
int preferenceType) |
Checks if this (similarity, reference value) pair strictly dominates another one, another pair strictly dominates this one,
pairs are equal or incomparable.
|
java.lang.Integer |
compareTo(Field object) |
Compares other field to this field.
|
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 (similarity, reference value) pair of simple values equal to this one
|
SimpleField |
getReferenceValue() |
Reads reference value.
|
java.lang.Class<? extends SimpleField> |
getReferenceValueType() |
Gets type of reference value stored in this (similarity, reference value) pair.
|
SimpleField |
getSimilarity() |
Reads similarity value.
|
java.lang.Class<? extends SimpleField> |
getSimilarityType() |
Gets type of similarity value stored in this (similarity, reference value) pair.
|
boolean |
isSimilarTo(Field field) |
Tests if given field's type is similar to this one.
|
int |
isUnknown() |
Tests if pair's elements are determined.
|
void |
setUnknown() |
Makes pair unknown.
|
java.lang.String |
toString() |
Returns a
String which represents value of this field. |
isGenerated, setGeneratedpublic static int numberOfSimilarityDecimalPlaces
FloatField.)
Used only if not less than zero. Otherwise default precision is used.public 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
(similarity value from this pair is equal to similarity value from another pair and
reference value from this pair is equal to reference value from another pair)public static final int ANOTHER_PAIR_IS_INCOMPARABLE
checkDominance method to indicate that this and another pair are incomparablepublic SimilarityField(SimpleField similarity, SimpleField referenceValue)
getSimilarity or getReferenceValue methods.
Type of both elements does not have to be the same.similarity - similarity valuereferenceValue - reference valuejava.lang.NullPointerException - if similarity or reference value is nullpublic SimpleField getSimilarity()
public SimpleField getReferenceValue()
public void copy(Field field)
copy in class Fieldfield - object which is a (similarity, reference value) pair with simple fields of the same type as this pairInvalidTypeException - when given field is not SimilarityField or if simple fields cannot be copiedjava.lang.NullPointerException - if given field is nullpublic Field duplicate()
public java.lang.Class<? extends SimpleField> getSimilarityType()
public java.lang.Class<? extends SimpleField> getReferenceValueType()
public boolean isSimilarTo(Field field)
isSimilarTo in class Fieldfield - compared field (pair)true if both fields are pairs with similar corresponding 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.
If numberOfSimilarityDecimalPlaces >= 0 and similarity is of type FloatField,
then it gets rounded to the required number of decimal places.toString in class java.lang.Objectpublic int isUnknown()
public void setUnknown()
setUnknown in class Fieldpublic int checkDominance(SimilarityField anotherPair, int preferenceType)
SimpleField.compareTo method.
If preference type is Attribute.NONE, then it is only checked if pairs are equal or incomparable.anotherPair - another (similarity, reference value) 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 type of similarity or reference value for checked another pair is different than corresponding type for this pairInvalidValueException - when preference type is none of Attribute.NONE,
Attribute.GAIN and Attribute.COSTpublic boolean equals(java.lang.Object object)
equals in class java.lang.Objectobject - object to checktrue if given object is also a (similarity, reference value) pair of simple values equal to this one, false otherwisepublic boolean checkConstraints()
CompoundFieldcheckConstraints in class CompoundFieldtrue if everything is in orderCompoundField.checkConstraints()public java.lang.Integer compareTo(Field object)
object - other field to compare with