Package com.appiancorp.common.query
Class FacetOption<T>
java.lang.Object
com.appiancorp.common.query.FacetOption<T>
- Type Parameters:
T- the type of values in the facet option filters
- All Implemented Interfaces:
com.appiancorp.common.query.ReadOnlyFacetOption
- Direct Known Subclasses:
GenericFacetOption,TypedValueFacetOption
@GwtCompatible
public abstract class FacetOption<T>
extends Object
implements com.appiancorp.common.query.ReadOnlyFacetOption
This class holds the metadata for an individual option for a facet. The key piece of
metadata of a facet option is the filters that should be applied when that facet is selected. For
example:
- a "Color" facet could have the option "Black" which specifies a single filter:
color = black - a "Closing Date" facet could have the option "1st Quarter" which specifies the filters:
closingDate >= 2012-01-01andclosingDate < 2012-04-01
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedDefault constructor, provided only for JAXB serialization.protectedConstructs a new facet option.protectedConstructs a new facet option.protectedFacetOption(String name, List<Filter<T>> filters, boolean isApplied, int dataCount) This is for creating a facet using design time data (a facet that does not yet have an ID since it has not been persisted). -
Method Summary
Modifier and TypeMethodDescriptionstatic com.google.common.base.Equivalence<FacetOption<?>>booleanCompares the given object by checking that it's an instance ofFacetOptionand has the sameidas this option.static <T> List<FacetOption<T>>getAppliedOptions(Iterable<FacetOption<T>> opts) Returns a subset of the given options which are the applied options (ie, options whoseisAppliedproperty is set totrue).intabstract Criteriacom.google.common.collect.ImmutableList<com.appiancorp.common.query.ReadOnlyFilter>getId()getName()inthashCode()Returns a hash code that uses theidproperty only.booleanIndicates whether the filters of this option are applied to the current data set.static com.google.common.base.Predicate<FacetOption<?>>voidsetApplied(boolean isApplied) Sets whether this option is selected or not.voidsetDataCount(int dataCount) Sets the number of objects whose data matches the filters of this option.protected abstract voidsetFilters(List<Filter<T>> filters) Sets the list of filters to add to a query when this option is selected.toString()
-
Field Details
-
XML_ROOT_ELEMENT
- See Also:
-
LOCAL_PART
- See Also:
-
QNAME
-
COUNT_NOT_AVAILABLE
public static final int COUNT_NOT_AVAILABLEThe value used when a count is not available. For example, seegetDataCount(),Facet.getOmittedOptionsDataCount(), etc.- See Also:
-
-
Constructor Details
-
FacetOption
protected FacetOption()Default constructor, provided only for JAXB serialization. Sub-classes should not expose a public default constructor. -
FacetOption
Constructs a new facet option. TheisAppliedproperty is set tofalse, and thedataCountproperty is set toCOUNT_NOT_AVAILABLE.- Parameters:
id- the id of this optionname- the name of this optionfilters- the list of filters to add to a query when this option is selected
-
FacetOption
protected FacetOption(String id, String name, List<Filter<T>> filters, boolean isApplied, int dataCount) Constructs a new facet option.- Parameters:
id- the id of this optionname- the name of this optionfilters- the list of filters to add to a query when this option is selectedisApplied- whether this option is selected or notdataCount- the number of objects whose data matches the filters of this option
-
FacetOption
This is for creating a facet using design time data (a facet that does not yet have an ID since it has not been persisted). This is necessary to show designers the performance of their record types using changes they have not yet saved.- Parameters:
name- the name of this optionfilters- the list of filters to add to a query when this option is selectedisApplied- whether this option is selected or notdataCount- the number of objects whose data matches the filters of this option
-
-
Method Details
-
getId
- Specified by:
getIdin interfacecom.appiancorp.common.query.ReadOnlyFacetOption<T>- Returns:
- The id of this option.
-
getName
- Specified by:
getNamein interfacecom.appiancorp.common.query.ReadOnlyFacetOption<T>- Returns:
- The name of this option.
-
isApplied
public boolean isApplied()Indicates whether the filters of this option are applied to the current data set.- Specified by:
isAppliedin interfacecom.appiancorp.common.query.ReadOnlyFacetOption<T>- Returns:
trueif this option is applied andfalseotherwise.
-
setApplied
public void setApplied(boolean isApplied) Sets whether this option is selected or not.- Parameters:
isApplied-trueif this option is applied andfalseotherwise.
-
getDataCount
public int getDataCount()- Specified by:
getDataCountin interfacecom.appiancorp.common.query.ReadOnlyFacetOption<T>- Returns:
- The number of objects whose data matches the filters of this option.
If this number is not available, returns
COUNT_NOT_AVAILABLE.
-
setDataCount
public void setDataCount(int dataCount) Sets the number of objects whose data matches the filters of this option.- Parameters:
dataCount- the number of objects whose data for this facet matches this option
-
getFilters
- Returns:
- The list of filters to add to a query when this option is selected.
-
getFiltersReadOnly
public com.google.common.collect.ImmutableList<com.appiancorp.common.query.ReadOnlyFilter> getFiltersReadOnly()- Specified by:
getFiltersReadOnlyin interfacecom.appiancorp.common.query.ReadOnlyFacetOption<T>
-
setFilters
Sets the list of filters to add to a query when this option is selected.- Parameters:
filters- the list of filters
-
getFiltersAsCriteria
- Specified by:
getFiltersAsCriteriain interfacecom.appiancorp.common.query.ReadOnlyFacetOption<T>- Returns:
- This option's filters wrapped in a criteria if needed.
-
toString
-
hashCode
public int hashCode()Returns a hash code that uses theidproperty only. -
equals
Compares the given object by checking that it's an instance ofFacetOptionand has the sameidas this option. -
equalDataCheck
- Returns:
- An equivalence implementation that checks all properties of
FacetOption.
-
isAppliedPredicate
- Returns:
- A predicate that returns
trueif the given option'sisApplied()property istrue, andfalseotherwise.
-
getAppliedOptions
Returns a subset of the given options which are the applied options (ie, options whoseisAppliedproperty is set totrue).- Parameters:
opts- the options to filter- Returns:
- the enabled options
-