Class AbstractFuzzyMatcher<T>
java.lang.Object
com.comphenix.protocol.reflect.fuzzy.AbstractFuzzyMatcher<T>
- All Implemented Interfaces:
Comparable<AbstractFuzzyMatcher<T>>
- Direct Known Subclasses:
AbstractFuzzyMember,FuzzyClassContract
public abstract class AbstractFuzzyMatcher<T>
extends Object
implements Comparable<AbstractFuzzyMatcher<T>>
Represents a matcher for fields, methods, constructors and classes.
This class should ideally never expose mutable state. Its round number must be immutable.
- Author:
- Kristian
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionand(AbstractFuzzyMatcher<T> other)Require that this and the given matcher be TRUE.protected abstract intCalculate the round number indicating when this matcher should be applied.protected intcombineRounds(int roundA, int roundB)Combine two round numbers by taking the highest non-zero number, or return zero.protected intcombineRounds(Integer... rounds)Combine n round numbers by taking the highest non-zero number, or return zero.intcompareTo(AbstractFuzzyMatcher<T> obj)intRetrieve the cached round number.inverted()Create a fuzzy matcher that returns the opposite result of the current matcher.abstract booleanDetermine if the given value is a match.or(AbstractFuzzyMatcher<T> other)Require that either this or the other given matcher be TRUE.
-
Constructor Details
-
AbstractFuzzyMatcher
public AbstractFuzzyMatcher()
-
-
Method Details
-
isMatch
Determine if the given value is a match.- Parameters:
value- - the value to match.parent- - the parent container, or NULL if this value is the root.- Returns:
- TRUE if it is a match, FALSE otherwise.
-
calculateRoundNumber
protected abstract int calculateRoundNumber()Calculate the round number indicating when this matcher should be applied.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
Integerwill have a lower round number thanNumber.- Returns:
- A number (positive or negative) that is used to order matchers.
-
getRoundNumber
public final int getRoundNumber()Retrieve the cached round number. This should never change once calculated.Matchers with a lower round number are applied before matchers with a higher round number.
- Returns:
- The round number.
- See Also:
calculateRoundNumber()
-
combineRounds
protected final int combineRounds(int roundA, int roundB)Combine two round numbers by taking the highest non-zero number, or return zero.- Parameters:
roundA- - the first round number.roundB- - the second round number.- Returns:
- The combined round number.
-
combineRounds
Combine n round numbers by taking the highest non-zero number, or return zero.- Parameters:
rounds- - the round numbers.- Returns:
- The combined round number.
-
compareTo
- Specified by:
compareToin interfaceComparable<T>
-
inverted
Create a fuzzy matcher that returns the opposite result of the current matcher.- Returns:
- An inverted fuzzy matcher.
-
and
Require that this and the given matcher be TRUE.- Parameters:
other- - the other fuzzy matcher.- Returns:
- A combined fuzzy matcher.
-
or
Require that either this or the other given matcher be TRUE.- Parameters:
other- - the other fuzzy matcher.- Returns:
- A combined fuzzy matcher.
-