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 and closingDate < 2012-04-01
  • Field Details

  • Constructor Details

    • FacetOption

      protected FacetOption()
      Default constructor, provided only for JAXB serialization. Sub-classes should not expose a public default constructor.
    • FacetOption

      protected FacetOption(String id, String name, List<Filter<T>> filters)
      Constructs a new facet option. The isApplied property is set to false, and the dataCount property is set to COUNT_NOT_AVAILABLE.
      Parameters:
      id - the id of this option
      name - the name of this option
      filters - 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 option
      name - the name of this option
      filters - the list of filters to add to a query when this option is selected
      isApplied - whether this option is selected or not
      dataCount - the number of objects whose data matches the filters of this option
    • FacetOption

      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). 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 option
      filters - the list of filters to add to a query when this option is selected
      isApplied - whether this option is selected or not
      dataCount - the number of objects whose data matches the filters of this option
  • Method Details

    • getId

      public String getId()
      Specified by:
      getId in interface com.appiancorp.common.query.ReadOnlyFacetOption<T>
      Returns:
      The id of this option.
    • getName

      public String getName()
      Specified by:
      getName in interface com.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 interface com.appiancorp.common.query.ReadOnlyFacetOption<T>
      Returns:
      true if this option is applied and false otherwise.
    • setApplied

      public void setApplied(boolean isApplied)
      Sets whether this option is selected or not.
      Parameters:
      isApplied - true if this option is applied and false otherwise.
    • getDataCount

      public int getDataCount()
      Specified by:
      getDataCount in interface com.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

      public abstract List<Filter<T>> 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 interface com.appiancorp.common.query.ReadOnlyFacetOption<T>
    • setFilters

      protected abstract void setFilters(List<Filter<T>> filters)
      Sets the list of filters to add to a query when this option is selected.
      Parameters:
      filters - the list of filters
    • getFiltersAsCriteria

      public abstract Criteria getFiltersAsCriteria()
      Specified by:
      getFiltersAsCriteria in interface com.appiancorp.common.query.ReadOnlyFacetOption<T>
      Returns:
      This option's filters wrapped in a criteria if needed.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • hashCode

      public int hashCode()
      Returns a hash code that uses the id property only.

      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Compares the given object by checking that it's an instance of FacetOption and has the same id as this option.

      Overrides:
      equals in class Object
    • equalDataCheck

      public static com.google.common.base.Equivalence<FacetOption<?>> equalDataCheck()
      Returns:
      An equivalence implementation that checks all properties of FacetOption.
    • isAppliedPredicate

      public static com.google.common.base.Predicate<FacetOption<?>> isAppliedPredicate()
      Returns:
      A predicate that returns true if the given option's isApplied() property is true, and false otherwise.
    • getAppliedOptions

      public static <T> List<FacetOption<T>> getAppliedOptions(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).
      Parameters:
      opts - the options to filter
      Returns:
      the enabled options