T
- the type of values in the facet option filters@GwtCompatible
public abstract class FacetOption<T>
extends java.lang.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:
color = black
closingDate >= 2012-01-01
and closingDate < 2012-04-01
Modifier and Type | Field and Description |
---|---|
static int |
COUNT_NOT_AVAILABLE
The value used when a count is not available.
|
static java.lang.String |
LOCAL_PART |
static javax.xml.namespace.QName |
QNAME |
protected static java.lang.String |
XML_ROOT_ELEMENT |
Modifier | Constructor and Description |
---|---|
protected |
FacetOption()
Default constructor, provided only for JAXB serialization.
|
protected |
FacetOption(java.lang.String name,
java.util.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).
|
protected |
FacetOption(java.lang.String id,
java.lang.String name,
java.util.List<Filter<T>> filters)
Constructs a new facet option.
|
protected |
FacetOption(java.lang.String id,
java.lang.String name,
java.util.List<Filter<T>> filters,
boolean isApplied,
int dataCount)
Constructs a new facet option.
|
Modifier and Type | Method and Description |
---|---|
static com.google.common.base.Equivalence<FacetOption<?>> |
equalDataCheck() |
boolean |
equals(java.lang.Object obj)
Compares the given object by checking that it's an instance of
FacetOption and has the same
id as this option. |
static <T> java.util.List<FacetOption<T>> |
getAppliedOptions(java.lang.Iterable<FacetOption<T>> opts)
Returns a subset of the given options which are the applied options (ie, options whose
isApplied property is set to true ). |
int |
getDataCount() |
abstract java.util.List<Filter<T>> |
getFilters() |
abstract Criteria |
getFiltersAsCriteria() |
com.google.common.collect.ImmutableList<com.appiancorp.common.query.ReadOnlyFilter> |
getFiltersReadOnly() |
java.lang.String |
getId() |
java.lang.String |
getName() |
int |
hashCode()
Returns a hash code that uses the
id property only. |
boolean |
isApplied()
Indicates whether the filters of this option are applied to the current data set.
|
static com.google.common.base.Predicate<FacetOption<?>> |
isAppliedPredicate() |
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(java.util.List<Filter<T>> filters)
Sets the list of filters to add to a query when this option is selected.
|
java.lang.String |
toString() |
protected static final java.lang.String XML_ROOT_ELEMENT
public static final java.lang.String LOCAL_PART
public static final javax.xml.namespace.QName QNAME
public static final int COUNT_NOT_AVAILABLE
getDataCount()
,
Facet.getOmittedOptionsDataCount()
, etc.protected FacetOption()
protected FacetOption(java.lang.String id, java.lang.String name, java.util.List<Filter<T>> filters)
isApplied
property is set to
false
, and the dataCount
property is set to COUNT_NOT_AVAILABLE
.id
- the id of this optionname
- the name of this optionfilters
- the list of filters to add to a query when this option is selectedprotected FacetOption(java.lang.String id, java.lang.String name, java.util.List<Filter<T>> filters, boolean isApplied, int dataCount)
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 optionprotected FacetOption(java.lang.String name, java.util.List<Filter<T>> filters, boolean isApplied, int dataCount)
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 optionpublic java.lang.String getId()
getId
in interface com.appiancorp.common.query.ReadOnlyFacetOption
public java.lang.String getName()
getName
in interface com.appiancorp.common.query.ReadOnlyFacetOption
public boolean isApplied()
isApplied
in interface com.appiancorp.common.query.ReadOnlyFacetOption
true
if this option is applied and false
otherwise.public void setApplied(boolean isApplied)
isApplied
- true
if this option is applied and false
otherwise.public int getDataCount()
getDataCount
in interface com.appiancorp.common.query.ReadOnlyFacetOption
COUNT_NOT_AVAILABLE
.public void setDataCount(int dataCount)
dataCount
- the number of objects whose data for this facet matches this optionpublic abstract java.util.List<Filter<T>> getFilters()
public com.google.common.collect.ImmutableList<com.appiancorp.common.query.ReadOnlyFilter> getFiltersReadOnly()
getFiltersReadOnly
in interface com.appiancorp.common.query.ReadOnlyFacetOption
protected abstract void setFilters(java.util.List<Filter<T>> filters)
filters
- the list of filterspublic abstract Criteria getFiltersAsCriteria()
getFiltersAsCriteria
in interface com.appiancorp.common.query.ReadOnlyFacetOption
public java.lang.String toString()
toString
in class java.lang.Object
public int hashCode()
id
property only.
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
FacetOption
and has the same
id
as this option.
equals
in class java.lang.Object
public static com.google.common.base.Equivalence<FacetOption<?>> equalDataCheck()
FacetOption
.public static com.google.common.base.Predicate<FacetOption<?>> isAppliedPredicate()
true
if the given option's isApplied()
property is
true
, and false
otherwise.public static <T> java.util.List<FacetOption<T>> getAppliedOptions(java.lang.Iterable<FacetOption<T>> opts)
isApplied
property is set to true
).opts
- the options to filterCopyright © 2003-2024 Appian Corporation. All Rights Reserved.