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
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedFacet()Default constructor, provided only for JAXB serialization.protectedFacet(String name, boolean isVisible, String defaultOption, List<FacetOption<T>> options, int numOmittedOptions, int omittedOptionsDataCount, boolean isExclusiveOptions, String facetType, String sourceRef) Constructs a new facet.protectedFacet(String name, boolean isVisible, String defaultOption, List<String> defaultOptions, List<FacetOption<T>> options, int numOmittedOptions, int omittedOptionsDataCount, boolean isExclusiveOptions, String facetType, String sourceRef) -
Method Summary
Modifier and TypeMethodDescriptionstatic com.google.common.base.Equivalence<Facet<?>>booleanfindOptionById(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()intintabstract List<FacetOption<T>>com.google.common.collect.ImmutableList<com.appiancorp.common.query.ReadOnlyFacetOption<T>>intinthashCode()Returns a hash code that uses thenameproperty only.booleanbooleanstatic com.appian.core.base.ToStringFunction<Facet<?>>multilineToString(int indent) Returns a function that generates a multi-line String representation of a facet.voidsetAppliedOptions(Criteria appliedCriteria) Sets theisAppliedproperty on the options of this facet, based on the given query criteria.static <T> voidsetAppliedOptions(Iterable<Facet<T>> facets, Criteria appliedCriteria) Sets theisAppliedproperty on the appropriate options of the given facets, usingsetAppliedOptions(Criteria).protected abstract voidsetOptions(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.
-
Facet
-
-
Method Details
-
getName
- Specified by:
getNamein interfacecom.appiancorp.common.query.ReadOnlyFacet<T>- Returns:
- The name of this facet.
-
isVisible
public boolean isVisible()- Specified by:
isVisiblein interfacecom.appiancorp.common.query.ReadOnlyFacet<T>- Returns:
- whether or not this facet should be displayed to the user.
-
getDefaultOption
- Specified by:
getDefaultOptionin interfacecom.appiancorp.common.query.ReadOnlyFacet<T>- Returns:
- the default applied option for the facet.
-
getDefaultOptions
- Specified by:
getDefaultOptionsin interfacecom.appiancorp.common.query.ReadOnlyFacet<T>
-
getNumOmittedOptions
public int getNumOmittedOptions()- Specified by:
getNumOmittedOptionsin 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
optionsplus the number ofomitted options. If the number of omitted options is not available, returnsFacetOption.COUNT_NOT_AVAILABLE.
-
getOmittedOptionsDataCount
public int getOmittedOptionsDataCount()- Specified by:
getOmittedOptionsDataCountin 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:
isExclusiveOptionsin interfacecom.appiancorp.common.query.ReadOnlyFacet<T>- Returns:
trueif the options are exclusive, andfalseotherwise. 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:
getFacetTypein interfacecom.appiancorp.common.query.ReadOnlyFacet<T>
-
getSourceRef
- Specified by:
getSourceRefin 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:
getOptionsReadOnlyin interfacecom.appiancorp.common.query.ReadOnlyFacet<T>
-
getAppliedOptions
- Returns:
- The subset of this facet's options that are applied (ie, options whose
isAppliedproperty is set totrue).
-
setAppliedOptions
Sets theisAppliedproperty on the options of this facet, based on the given query criteria.An option's
isAppliedproperty will be set totrue, if that option'sfiltersare contained in the given criteria. Otherwise, theisAppliedproperty will be set tofalse.- Parameters:
appliedCriteria- the criteria to use in order to determine which facet options are enabled
-
setAppliedOptions
Sets theisAppliedproperty 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:
findOptionByIdReadOnlyin 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 thenameproperty only. -
equals
-
equalDataCheck
- Returns:
- An equivalence that checks all properties of
Facet.
-