Interface ChooserFilter<T>
public interface ChooserFilter<T>
An interface used to filter elements that are possible to choose from a
ChooserWidget<T>
. A ChooserWidget must consult it's filter (if it has
one) before presenting a certain element as choosable. Typically, a ChooserWidget
should never call anything except the accept method of its filter. Other methods
are meant to be used by the choosers container (if any). This is of course
not mandated, only suggested. The chooser is free to call any methods - but
it is mandated to call accept for any element before presenting that element
as a valid choice.- Author:
- Per-Erik
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Returns true if this filter accepts the given element, false otherwise.Returns a displayable name of this filter when the filter is turned on.boolean
Returnstrue
if filtering is currently on.boolean
Returns true if this filter is intended to be a rule rather than a filter.void
setFilteringOn
(boolean filteringOn) If filteringOn is false, tells this filter that it no longer has to filter if it isn't deemed required by the filter.
-
Method Details
-
accept
Returns true if this filter accepts the given element, false otherwise.- Parameters:
element
- The element to test for acceptance.- Returns:
- true if this filter accepts the given element, false otherwise
-
isFilteringOn
boolean isFilteringOn()Returnstrue
if filtering is currently on. Filters that return true from isRuleFilter() will typically returnfalse
even if filtering has been turned on by calling setFilteringOn(true).- Returns:
true
if filtering is currently on.
-
setFilteringOn
void setFilteringOn(boolean filteringOn) If filteringOn is false, tells this filter that it no longer has to filter if it isn't deemed required by the filter. It is however up to the filter to determine if filtering should be done or not. If filteringOn is true, tells this filter that it must filter values. Implementations may opt out of this by always filter no matter the value of filteringOn. It may not opt out by never filtering (defeating the purpose of a filter).
Typically, filters that return true from isRuleFilter() will ignore this call and thus always filter in accept.- Parameters:
filteringOn
-
-
isRuleFilter
boolean isRuleFilter()Returns true if this filter is intended to be a rule rather than a filter. If true, users of the filter should not apply it and deapply it. Once applied, it should stay applied for the continuation of the choosers lifetime.
This is mainly usefull when constructing chooser dialogs, not so much for the chooser itself. The dialog (container) containing the chooser can however use this to determine if the user should be able to turn off filters, change filters and so on.- Returns:
- True if this filter is to be seen as a rule upholder rather than a filter, false otherwise.
-
getFilteredName
String getFilteredName()Returns a displayable name of this filter when the filter is turned on.- Returns:
- a displayable name of this filter when the filter is turned on.
-