Package ca.odell.glazedlists.matchers
Class ThresholdMatcherEditor<E,T>
- java.lang.Object
-
- ca.odell.glazedlists.matchers.AbstractMatcherEditorListenerSupport<E>
-
- ca.odell.glazedlists.matchers.AbstractMatcherEditor<E>
-
- ca.odell.glazedlists.matchers.ThresholdMatcherEditor<E,T>
-
- All Implemented Interfaces:
MatcherEditor<E>
public class ThresholdMatcherEditor<E,T> extends AbstractMatcherEditor<E>
AMatcherEditorthat filters elements based on whether they are greater than or less than a threshold. The implementation is based on elements implementingComparableunless the constructor specifies aComparator. By default the elements themselves are compared with the threshold value, however, an optional Function can be provided which can be used to extract a value that is appropriate for comparison with the threshold. In this way, ThreshholdMatcherEditor provides a level of indirection when locating the exact value to compare for a given element.- Author:
- Rob Eden
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface ca.odell.glazedlists.matchers.MatcherEditor
MatcherEditor.Event<E>, MatcherEditor.Listener<E>
-
-
Field Summary
Fields Modifier and Type Field Description static ca.odell.glazedlists.matchers.ThresholdMatcherEditor.MatchOperationEQUALstatic ca.odell.glazedlists.matchers.ThresholdMatcherEditor.MatchOperationGREATER_THANstatic ca.odell.glazedlists.matchers.ThresholdMatcherEditor.MatchOperationGREATER_THAN_OR_EQUALstatic ca.odell.glazedlists.matchers.ThresholdMatcherEditor.MatchOperationLESS_THANstatic ca.odell.glazedlists.matchers.ThresholdMatcherEditor.MatchOperationLESS_THAN_OR_EQUALstatic ca.odell.glazedlists.matchers.ThresholdMatcherEditor.MatchOperationNOT_EQUAL
-
Constructor Summary
Constructors Constructor Description ThresholdMatcherEditor()Construct an instance that will require elements to be greater than the threshold (which is not initially set) and relies on the threshold object and elements in the list implementingComparable.ThresholdMatcherEditor(T threshold)Construct an instance that will require elements to be greater than the given threshold and relies on the threshold object and elements in the list implementingComparable.ThresholdMatcherEditor(T threshold, ca.odell.glazedlists.matchers.ThresholdMatcherEditor.MatchOperation operation)Construct an instance that will require elements to be greater than the given threshold and relies on the threshold object and elements in the list implementingComparable.ThresholdMatcherEditor(T threshold, ca.odell.glazedlists.matchers.ThresholdMatcherEditor.MatchOperation operation, java.util.Comparator<T> comparator)Construct an instance.ThresholdMatcherEditor(T threshold, ca.odell.glazedlists.matchers.ThresholdMatcherEditor.MatchOperation operation, java.util.Comparator<T> comparator, FunctionList.Function<E,T> function)Construct an instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Comparator<T>getComparator()ca.odell.glazedlists.matchers.ThresholdMatcherEditor.MatchOperationgetMatchOperation()TgetThreshold()SeegetThreshold().voidsetComparator(java.util.Comparator<T> comparator)Update the comparator.voidsetMatchOperation(ca.odell.glazedlists.matchers.ThresholdMatcherEditor.MatchOperation operation)Update the operation used to determine what relation list elements should have to the threshold in order to match (i.e.voidsetThreshold(T threshold)Update the threshold used to determine what is matched by the list.-
Methods inherited from class ca.odell.glazedlists.matchers.AbstractMatcherEditor
fireChanged, fireConstrained, fireMatchAll, fireMatchNone, fireRelaxed, getMatcher, isCurrentlyMatchingAll, isCurrentlyMatchingNone
-
Methods inherited from class ca.odell.glazedlists.matchers.AbstractMatcherEditorListenerSupport
addMatcherEditorListener, createChangedEvent, createConstrainedEvent, createMatchAllEvent, createMatchNoneEvent, createRelaxedEvent, fireChangedMatcher, removeMatcherEditorListener
-
-
-
-
Field Detail
-
GREATER_THAN
public static final ca.odell.glazedlists.matchers.ThresholdMatcherEditor.MatchOperation GREATER_THAN
-
GREATER_THAN_OR_EQUAL
public static final ca.odell.glazedlists.matchers.ThresholdMatcherEditor.MatchOperation GREATER_THAN_OR_EQUAL
-
LESS_THAN
public static final ca.odell.glazedlists.matchers.ThresholdMatcherEditor.MatchOperation LESS_THAN
-
LESS_THAN_OR_EQUAL
public static final ca.odell.glazedlists.matchers.ThresholdMatcherEditor.MatchOperation LESS_THAN_OR_EQUAL
-
EQUAL
public static final ca.odell.glazedlists.matchers.ThresholdMatcherEditor.MatchOperation EQUAL
-
NOT_EQUAL
public static final ca.odell.glazedlists.matchers.ThresholdMatcherEditor.MatchOperation NOT_EQUAL
-
-
Constructor Detail
-
ThresholdMatcherEditor
public ThresholdMatcherEditor()
Construct an instance that will require elements to be greater than the threshold (which is not initially set) and relies on the threshold object and elements in the list implementingComparable.
-
ThresholdMatcherEditor
public ThresholdMatcherEditor(T threshold)
Construct an instance that will require elements to be greater than the given threshold and relies on the threshold object and elements in the list implementingComparable.- Parameters:
threshold- the initial threshold, or null if none.
-
ThresholdMatcherEditor
public ThresholdMatcherEditor(T threshold, ca.odell.glazedlists.matchers.ThresholdMatcherEditor.MatchOperation operation)
Construct an instance that will require elements to be greater than the given threshold and relies on the threshold object and elements in the list implementingComparable.- Parameters:
threshold- the initial threshold, or null if none.operation- the operation to determine what relation list elements should have to the threshold in order to match (i.e., be visible). Specifying null will useGREATER_THAN.
-
ThresholdMatcherEditor
public ThresholdMatcherEditor(T threshold, ca.odell.glazedlists.matchers.ThresholdMatcherEditor.MatchOperation operation, java.util.Comparator<T> comparator)
Construct an instance.- Parameters:
threshold- rhe initial threshold, or null if none.operation- rhe operation to determine what relation list elements should have to the threshold in order to match (i.e., be visible). Specifying null will useGREATER_THAN.comparator- determines how objects compare. If null, the threshold object and list elements must implementComparable.
-
ThresholdMatcherEditor
public ThresholdMatcherEditor(T threshold, ca.odell.glazedlists.matchers.ThresholdMatcherEditor.MatchOperation operation, java.util.Comparator<T> comparator, FunctionList.Function<E,T> function)
Construct an instance.- Parameters:
threshold- the initial threshold, or null if none.operation- the operation to determine what relation list elements should have to the threshold in order to match (i.e., be visible). Specifying null will useGREATER_THAN.comparator- determines how objects compare with the threshold value. If null, the threshold object and list elements must implementComparable.function- an optional Function which produces a value fit to be compared against the threshold. This argument is optional, and if it is null, the raw values will compared against the threshold.
-
-
Method Detail
-
setThreshold
public void setThreshold(T threshold)
Update the threshold used to determine what is matched by the list. This coupled with thematch operationdetermines what's matched.- Parameters:
threshold- The threshold, or null to match everything.
-
getThreshold
public T getThreshold()
SeegetThreshold().
-
setMatchOperation
public void setMatchOperation(ca.odell.glazedlists.matchers.ThresholdMatcherEditor.MatchOperation operation)
Update the operation used to determine what relation list elements should have to the threshold in order to match (i.e. be visible). Must be non-null.- See Also:
GREATER_THAN,GREATER_THAN_OR_EQUAL,LESS_THAN,LESS_THAN_OR_EQUAL,EQUAL,NOT_EQUAL
-
getMatchOperation
public ca.odell.glazedlists.matchers.ThresholdMatcherEditor.MatchOperation getMatchOperation()
-
setComparator
public void setComparator(java.util.Comparator<T> comparator)
Update the comparator. Setting to null will require that thresholds and elements in the list implementComparable.
-
getComparator
public java.util.Comparator<T> getComparator()
-
-