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-01
andclosingDate < 2012-04-01
-
Field Summary
-
Constructor Summary
ModifierConstructorDescriptionprotected
Default constructor, provided only for JAXB serialization.protected
Constructs a new facet option.protected
Constructs a new facet option.protected
FacetOption
(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<?>>
boolean
Compares the given object by checking that it's an instance ofFacetOption
and has the sameid
as 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 whoseisApplied
property is set totrue
).int
abstract Criteria
com.google.common.collect.ImmutableList<com.appiancorp.common.query.ReadOnlyFilter>
getId()
getName()
int
hashCode()
Returns a hash code that uses theid
property only.boolean
Indicates whether the filters of this option are applied to the current data set.static com.google.common.base.Predicate<FacetOption<?>>
void
setApplied
(boolean isApplied) Sets whether this option is selected or not.void
setDataCount
(int dataCount) Sets the number of objects whose data matches the filters of this option.protected abstract void
setFilters
(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. TheisApplied
property is set tofalse
, and thedataCount
property 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:
getId
in interfacecom.appiancorp.common.query.ReadOnlyFacetOption<T>
- Returns:
- The id of this option.
-
getName
- Specified by:
getName
in 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:
isApplied
in interfacecom.appiancorp.common.query.ReadOnlyFacetOption<T>
- Returns:
true
if this option is applied andfalse
otherwise.
-
setApplied
public void setApplied(boolean isApplied) Sets whether this option is selected or not.- Parameters:
isApplied
-true
if this option is applied andfalse
otherwise.
-
getDataCount
public int getDataCount()- Specified by:
getDataCount
in 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:
getFiltersReadOnly
in 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:
getFiltersAsCriteria
in 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 theid
property only. -
equals
Compares the given object by checking that it's an instance ofFacetOption
and has the sameid
as this option. -
equalDataCheck
- Returns:
- An equivalence implementation that checks all properties of
FacetOption
.
-
isAppliedPredicate
- Returns:
- A predicate that returns
true
if the given option'sisApplied()
property istrue
, andfalse
otherwise.
-
getAppliedOptions
Returns a subset of the given options which are the applied options (ie, options whoseisApplied
property is set totrue
).- Parameters:
opts
- the options to filter- Returns:
- the enabled options
-