public abstract class AbstractFuzzyMatcher<T> extends java.lang.Object implements java.lang.Comparable<AbstractFuzzyMatcher<T>>
This class should ideally never expose mutable state. Its round number must be immutable.
Constructor and Description |
---|
AbstractFuzzyMatcher() |
Modifier and Type | Method and Description |
---|---|
AbstractFuzzyMatcher<T> |
and(AbstractFuzzyMatcher<T> other)
Require that this and the given matcher be TRUE.
|
protected abstract int |
calculateRoundNumber()
Calculate the round number indicating when this matcher should be applied.
|
protected int |
combineRounds(int roundA,
int roundB)
Combine two round numbers by taking the highest non-zero number, or return zero.
|
int |
compareTo(AbstractFuzzyMatcher<T> obj) |
int |
getRoundNumber()
Retrieve the cached round number.
|
AbstractFuzzyMatcher<T> |
inverted()
Create a fuzzy matcher that returns the opposite result of the current matcher.
|
abstract boolean |
isMatch(T value,
java.lang.Object parent)
Determine if the given value is a match.
|
AbstractFuzzyMatcher<T> |
or(AbstractFuzzyMatcher<T> other)
Require that either this or the other given matcher be TRUE.
|
public abstract boolean isMatch(T value, java.lang.Object parent)
value
- - the value to match.parent
- - the parent container, or NULL if this value is the root.protected abstract int calculateRoundNumber()
Matchers with a lower round number are applied before matchers with a higher round number.
By convention, this round number should be negative, except for zero in the case of a matcher
that accepts any value. A good implementation should return the inverted tree depth (class hierachy)
of the least specified type used in the matching. Thus Integer
will have a lower round number than
Number
.
public final int getRoundNumber()
Matchers with a lower round number are applied before matchers with a higher round number.
#calculateRoundNumber()}
protected final int combineRounds(int roundA, int roundB)
roundA
- - the first round number.roundB
- - the second round number.public int compareTo(AbstractFuzzyMatcher<T> obj)
compareTo
in interface java.lang.Comparable<AbstractFuzzyMatcher<T>>
public AbstractFuzzyMatcher<T> inverted()
public AbstractFuzzyMatcher<T> and(AbstractFuzzyMatcher<T> other)
other
- - the other fuzzy matcher.public AbstractFuzzyMatcher<T> or(AbstractFuzzyMatcher<T> other)
other
- - the other fuzzy matcher.