Package com.appiancorp.common.query
Class Facet<T>
java.lang.Object
com.appiancorp.common.query.Facet<T>
- Type Parameters:
T
- the type of values in the facet option filters
- All Implemented Interfaces:
com.appiancorp.common.query.ReadOnlyFacet<T>
- Direct Known Subclasses:
GenericFacet
,TypedValueFacet
@GwtCompatible
public abstract class Facet<T>
extends Object
implements com.appiancorp.common.query.ReadOnlyFacet<T>
This class holds the metadata for a facet and its options. For example, a Car record could have a Color facet with the options Black, White, Silver.
-
Field Summary
-
Constructor Summary
ModifierConstructorDescriptionprotected
Facet()
Default constructor, provided only for JAXB serialization.protected
Facet
(String name, boolean isVisible, String defaultOption, List<FacetOption<T>> options, int numOmittedOptions, int omittedOptionsDataCount, boolean isExclusiveOptions, String facetType, String sourceRef) Constructs a new facet. -
Method Summary
Modifier and TypeMethodDescriptionstatic com.google.common.base.Equivalence<Facet<?>>
boolean
findOptionById
(String facetOptionId) Finds an option by id.static <T> FacetOption<T>
findOptionById
(List<Facet<T>> facets, String facetOptionId) Finds the first matching option by id, within the options of the given facets.com.appiancorp.common.query.ReadOnlyFacetOption<T>
findOptionByIdReadOnly
(String facetOptionId) static <T> com.appiancorp.common.query.ReadOnlyFacetOption<T>
findOptionByIdReadOnly
(List<com.appiancorp.common.query.ReadOnlyFacet<T>> facets, String facetOptionId) List<FacetOption<T>>
getName()
int
int
abstract List<FacetOption<T>>
com.google.common.collect.ImmutableList<com.appiancorp.common.query.ReadOnlyFacetOption<T>>
int
int
hashCode()
Returns a hash code that uses thename
property only.boolean
boolean
static com.appian.core.base.ToStringFunction<Facet<?>>
multilineToString
(int indent) Returns a function that generates a multi-line String representation of a facet.void
setAppliedOptions
(Criteria appliedCriteria) Sets theisApplied
property on the options of this facet, based on the given query criteria.static <T> void
setAppliedOptions
(Iterable<Facet<T>> facets, Criteria appliedCriteria) Sets theisApplied
property on the appropriate options of the given facets, usingsetAppliedOptions(Criteria)
.protected abstract void
setOptions
(List<FacetOption<T>> options) Sets the options for this facet.toString()
-
Field Details
-
XML_ROOT_ELEMENT
- See Also:
-
LOCAL_PART
- See Also:
-
QNAME
-
DEFAULT_OPTION
-
VISIBLE_BY_DEFAULT
public static final boolean VISIBLE_BY_DEFAULT- See Also:
-
-
Constructor Details
-
Facet
protected Facet()Default constructor, provided only for JAXB serialization. Sub-classes should not expose a public default constructor. -
Facet
protected Facet(String name, boolean isVisible, String defaultOption, List<FacetOption<T>> options, int numOmittedOptions, int omittedOptionsDataCount, boolean isExclusiveOptions, String facetType, String sourceRef) Constructs a new facet.- Parameters:
name
- The name of the facet.options
- The list of options for this facet.isVisible
- Whether or not the facet will appear to the user.defaultOption
- The defaultOption to be applied.numOmittedOptions
- The number of additional options that are available, but are not included in the provided list of options.omittedOptionsDataCount
- The number of objects that contain data matched by the omitted options. This allows the UI to present the generic option "Other" along with a count.isExclusiveOptions
- Whether this facet's options are exclusive or not. SeeisExclusiveOptions()
.facetType
- Type of the facet (whether it is List or DateRange)sourceRef
- Name of the field (of the record), on which the filter is applied.
-
-
Method Details
-
getName
- Specified by:
getName
in interfacecom.appiancorp.common.query.ReadOnlyFacet<T>
- Returns:
- The name of this facet.
-
isVisible
public boolean isVisible()- Specified by:
isVisible
in interfacecom.appiancorp.common.query.ReadOnlyFacet<T>
- Returns:
- whether or not this facet should be displayed to the user.
-
getDefaultOption
- Specified by:
getDefaultOption
in interfacecom.appiancorp.common.query.ReadOnlyFacet<T>
- Returns:
- the default applied option for the facet.
-
getNumOmittedOptions
public int getNumOmittedOptions()- Specified by:
getNumOmittedOptions
in interfacecom.appiancorp.common.query.ReadOnlyFacet<T>
- Returns:
- The number of options that exist, but are not included in
the list of options
. If this number is not available, returnsFacetOption.COUNT_NOT_AVAILABLE
.
-
getTotalNumOptions
public int getTotalNumOptions()- Returns:
- The number of
options
plus the number ofomitted options
. If the number of omitted options is not available, returnsFacetOption.COUNT_NOT_AVAILABLE
.
-
getOmittedOptionsDataCount
public int getOmittedOptionsDataCount()- Specified by:
getOmittedOptionsDataCount
in interfacecom.appiancorp.common.query.ReadOnlyFacet<T>
- Returns:
- The number of objects that have a value for this facet that matches one of the omitted options.
If this number is not available, returns
FacetOption.COUNT_NOT_AVAILABLE
.
-
isExclusiveOptions
public boolean isExclusiveOptions()- Specified by:
isExclusiveOptions
in interfacecom.appiancorp.common.query.ReadOnlyFacet<T>
- Returns:
true
if the options are exclusive, andfalse
otherwise. If the options are exclusive, only one of the options can be applied for a given query. If the options are not exclusive, multiple options can be selected and applied in a given query. This is analogous to radio buttons vs checkboxes.
-
getFacetType
- Specified by:
getFacetType
in interfacecom.appiancorp.common.query.ReadOnlyFacet<T>
-
getSourceRef
- Specified by:
getSourceRef
in interfacecom.appiancorp.common.query.ReadOnlyFacet<T>
-
getOptions
- Returns:
- The options of this facet.
-
setOptions
Sets the options for this facet.- Parameters:
options
- the list of options
-
getOptionsReadOnly
public com.google.common.collect.ImmutableList<com.appiancorp.common.query.ReadOnlyFacetOption<T>> getOptionsReadOnly()- Specified by:
getOptionsReadOnly
in interfacecom.appiancorp.common.query.ReadOnlyFacet<T>
-
getAppliedOptions
- Returns:
- The subset of this facet's options that are applied (ie, options whose
isApplied
property is set totrue
).
-
setAppliedOptions
Sets theisApplied
property on the options of this facet, based on the given query criteria.An option's
isApplied
property will be set totrue
, if that option'sfilters
are contained in the given criteria. Otherwise, theisApplied
property will be set tofalse
.- Parameters:
appliedCriteria
- the criteria to use in order to determine which facet options are enabled
-
setAppliedOptions
Sets theisApplied
property on the appropriate options of the given facets, usingsetAppliedOptions(Criteria)
.- Parameters:
facets
- the facets to configureappliedCriteria
- the criteria to use in order to determine which facet options are enabled
-
findOptionById
Finds an option by id.- Parameters:
facetOptionId
- the targetoption id
- Returns:
- If this facet's list of options contains an option with the given id, returns that option.
Otherwise, returns
null
.
-
findOptionByIdReadOnly
public com.appiancorp.common.query.ReadOnlyFacetOption<T> findOptionByIdReadOnly(String facetOptionId) - Specified by:
findOptionByIdReadOnly
in interfacecom.appiancorp.common.query.ReadOnlyFacet<T>
-
findOptionById
Finds the first matching option by id, within the options of the given facets.- Parameters:
facets
- the facets whose options should be searchedfacetOptionId
- the targetoption id
- Returns:
- If the given list of facets contains a facet with an option with the given id, returns that
option. Otherwise, returns
null
.
-
findOptionByIdReadOnly
-
toString
-
multilineToString
Returns a function that generates a multi-line String representation of a facet.- Parameters:
indent
- the indent to be used by the returned function- Returns:
- the "toString" function
-
hashCode
public int hashCode()Returns a hash code that uses thename
property only. -
equals
-
equalDataCheck
- Returns:
- An equivalence that checks all properties of
Facet
.
-