Class AdvancedFilterableSupport
java.lang.Object
com.vaadin.featurepack.data.jpacontainer.filter.util.AdvancedFilterableSupport
- All Implemented Interfaces:
AdvancedFilterable,Serializable
Helper class that implements the filtering methods defined in
AdvancedFilterable and can be either extended or used as a delegate.- Since:
- 1.0
- Author:
- Petter Holmström (Vaadin Ltd)
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceApplyFiltersListener interface to be implemented by classes that want to be notified when the filters are applied.Nested classes/interfaces inherited from interface com.vaadin.featurepack.data.jpacontainer.AdvancedFilterable
AdvancedFilterable.FiltersAppliedEvent<C extends Container & AdvancedFilterable> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddFilter(Container.Filter filter) voidAddslistenerto the list of listeners to be notified when the filters are applied.voidApplies the filters to the data, possibly causing the items in the container to change.protected voidGets the list of filters that are currently applied.Gets the IDs of all the properties that are filterable.Gets the list of filters to apply.static jakarta.persistence.criteria.Path<String> getPropertyPath(jakarta.persistence.criteria.From<?, ?> root, Object propertyId) static <X,Y> jakarta.persistence.criteria.Path <X> getPropertyPathTyped(jakarta.persistence.criteria.From<X, Y> root, Object propertyId) booleanChecks if there are filters that have not yet been applied, or applied filters that have been removed usingorinvalid reference
#removeAllFilters().invalid reference
#removeFilter(com.vaadin.addon.jpacontainer.Filter)booleanReturns whether the filters should be applied immediately when a filter is added or removed.booleanisFilterable(Object propertyId) Checks ifpropertyIdis filterable.booleanisValidFilter(Container.Filter filter) Checks iffilteris a valid filter, i.e. that all the properties that the filter restricts are filterable.voidvoidremoveFilter(Container.Filter filter) voidRemoveslistenerfrom the list of listeners.voidsetApplyFiltersImmediately(boolean applyFiltersImmediately) Sets whether the filters should be applied immediately when a filter is added or removed.voidsetFilterablePropertyIds(Object... propertyIds) Sets the filterable property IDs.voidsetFilterablePropertyIds(Collection<?> propertyIds) Sets the filterable property IDs.
-
Constructor Details
-
AdvancedFilterableSupport
public AdvancedFilterableSupport()
-
-
Method Details
-
addListener
Addslistenerto the list of listeners to be notified when the filters are applied. The listener will be notified as many times as it has been added.- Parameters:
listener- the listener to add (must not be null).
-
removeListener
Removeslistenerfrom the list of listeners. If the listener has been added more than once, it will be notified one less time. If the listener has not been added at all, nothing happens.- Parameters:
listener- the listener to remove (must not be null).
-
fireListeners
protected void fireListeners() -
getFilterablePropertyIds
Description copied from interface:AdvancedFilterableGets the IDs of all the properties that are filterable.- Specified by:
getFilterablePropertyIdsin interfaceAdvancedFilterable- Returns:
- an unmodifiable collection of property IDs (never null).
- See Also:
-
setFilterablePropertyIds
Sets the filterable property IDs.- Parameters:
propertyIds- the property IDs to set (must not be null).
-
setFilterablePropertyIds
Sets the filterable property IDs.- Parameters:
propertyIds- the property IDs to set (must not be null).
-
isFilterable
Description copied from interface:AdvancedFilterableChecks ifpropertyIdis filterable.- Specified by:
isFilterablein interfaceAdvancedFilterable- Parameters:
propertyId- the property ID to check (must not be null).- Returns:
- true if the property is filterable, false otherwise.
- See Also:
-
isValidFilter
Checks iffilteris a valid filter, i.e. that all the properties that the filter restricts are filterable.- Parameters:
filter- the filter to check (must not be null).- Returns:
- true if the filter is valid, false if it is not.
-
getFilters
Description copied from interface:AdvancedFilterableGets the list of filters to apply. The filters will be applied as a conjunction (i.e. AND) in the order they appear in.- Specified by:
getFiltersin interfaceAdvancedFilterable- Returns:
- an unmodifiable list of filters (never null).
- See Also:
-
getAppliedFilters
Description copied from interface:AdvancedFilterableGets the list of filters that are currently applied. IfAdvancedFilterable.isApplyFiltersImmediately()returns true, this list will be the same as the one returned byAdvancedFilterable.getFilters().- Specified by:
getAppliedFiltersin interfaceAdvancedFilterable- Returns:
- an unmodifiable list of filters (never null).
- See Also:
-
setApplyFiltersImmediately
public void setApplyFiltersImmediately(boolean applyFiltersImmediately) Description copied from interface:AdvancedFilterableSets whether the filters should be applied immediately when a filter is added or removed.- Specified by:
setApplyFiltersImmediatelyin interfaceAdvancedFilterable- Parameters:
applyFiltersImmediately- true to apply filters immediately, false to apply whenAdvancedFilterable.applyFilters()is called.- See Also:
-
isApplyFiltersImmediately
public boolean isApplyFiltersImmediately()Description copied from interface:AdvancedFilterableReturns whether the filters should be applied immediately when a filter is added or removed. Default is true. If false,AdvancedFilterable.applyFilters()has to be called to apply the filters and update the container.- Specified by:
isApplyFiltersImmediatelyin interfaceAdvancedFilterable- Returns:
- true if the filters are applied immediately, false otherwise.
- See Also:
-
applyFilters
public void applyFilters()Description copied from interface:AdvancedFilterableApplies the filters to the data, possibly causing the items in the container to change.- Specified by:
applyFiltersin interfaceAdvancedFilterable- See Also:
-
hasUnappliedFilters
public boolean hasUnappliedFilters()Description copied from interface:AdvancedFilterableChecks if there are filters that have not yet been applied, or applied filters that have been removed usingorinvalid reference
#removeAllFilters().invalid reference
#removeFilter(com.vaadin.addon.jpacontainer.Filter)If
AdvancedFilterable.isApplyFiltersImmediately()is true, this method always returns false.- Specified by:
hasUnappliedFiltersin interfaceAdvancedFilterable- Returns:
- true if there are unapplied filters, false otherwise.
- See Also:
-
getPropertyPath
-
getPropertyPathTyped
public static <X,Y> jakarta.persistence.criteria.Path<X> getPropertyPathTyped(jakarta.persistence.criteria.From<X, Y> root, Object propertyId) -
addFilter
- Parameters:
filter-
-
removeFilter
- Parameters:
filter-
-
removeAllFilters
public void removeAllFilters()
-