Class SortOption

java.lang.Object
com.broadleafcommerce.search.api.domain.SortOption
All Implemented Interfaces:
com.broadleafcommerce.data.tracking.core.ContextStateAware, Serializable

public class SortOption extends Object implements Serializable, com.broadleafcommerce.data.tracking.core.ContextStateAware
A sorting option for a particular field. This sort can be performed in either ascending or descending order.

Since 2.1.0-GA, SortOptions are managed as independent entities from FieldDefinitions rather than being embedded.

See Also:
  • Constructor Details

    • SortOption

      public SortOption()
  • Method Details

    • getFieldDefinitionId

      public String getFieldDefinitionId()
    • getFieldIndexableType

      public String getFieldIndexableType()
    • getSortBehavior

      public String getSortBehavior()
    • getLabelBehavior

      public String getLabelBehavior()
    • getDisplayLabel

      public String getDisplayLabel()
      Returns a display label for this sort option. This is only used for display purposes in a grid.
    • getId

      public String getId()
      The context ID of the sort option.
      Returns:
      the context ID of the sort option
    • getLabel

      public String getLabel()
      The label of this sort option. This is the label that may be displayed to the user when the sort behavior is default and a label behavior of SortSettings.Labels.SINGLE.
    • getAscendingLabel

      public String getAscendingLabel()
      The "Ascending" label of this search option. Should be used if the sort behavior is ascending only or default.
      Since:
      Search Service 2.1.4, Release Train 2.1.4, Search Service 2.2.0, Release Train 2.2.0
    • getDescendingLabel

      public String getDescendingLabel()
      The "Descending" label of this search option. Should be used if the sort behavior is descending only or default.
      Since:
      Search Service 2.1.4, Release Train 2.1.4, Search Service 2.2.0, Release Train 2.2.0
    • getName

      public String getName()
      Name to use to identify the sort option. Typically, this should correspond to a FieldDefinition.getAbbreviation().
      Returns:
      Name to use to identify the sort option.
    • getField

      public FieldRef getField()
      The field to be sorted on. Only id, indexableType, and label are serialized in API responses.
      Returns:
      field to be sorted on
    • getVariantType

      public String getVariantType()
      The field variant type which should be sorted on.
    • getDisplayOrder

      public Integer getDisplayOrder()
      The display order of this sort option
      Returns:
      the order to display this sort option
    • getAttributes

      public Map<String,Object> getAttributes()
      Miscellaneous attributes for this sort option.
      Returns:
      Miscellaneous attributes for this sort option.
    • getContextState

      public com.broadleafcommerce.data.tracking.core.filtering.business.domain.ContextState getContextState()
      A subset of Tracking information to expose the context state for this object.
      Specified by:
      getContextState in interface com.broadleafcommerce.data.tracking.core.ContextStateAware
      Returns:
      a subset of Tracking information to expose the context state for this object
    • setId

      public void setId(String id)
      The context ID of the sort option.
      Parameters:
      id - the context ID of the sort option
    • setLabel

      public void setLabel(String label)
      The label of this sort option. This is the label that may be displayed to the user when the sort behavior is default and a label behavior of SortSettings.Labels.SINGLE.
    • setAscendingLabel

      public void setAscendingLabel(String ascendingLabel)
      The "Ascending" label of this search option. Should be used if the sort behavior is ascending only or default.
      Since:
      Search Service 2.1.4, Release Train 2.1.4, Search Service 2.2.0, Release Train 2.2.0
    • setDescendingLabel

      public void setDescendingLabel(String descendingLabel)
      The "Descending" label of this search option. Should be used if the sort behavior is descending only or default.
      Since:
      Search Service 2.1.4, Release Train 2.1.4, Search Service 2.2.0, Release Train 2.2.0
    • setSortBehavior

      public void setSortBehavior(String sortBehavior)
      The sorting behavior of this sort option. This is useful in cases where it may not make sense to sort in both ascending and descending order. For example, sorting by "In stock" or "Most Popular".

      Note that this doesn't actually enforce any behavior, but is a hint to the client on how to display the sort option.

      See SortSettings.Behavior.

      Since:
      Search Service 2.1.4, Release Train 2.1.4, Search Service 2.2.0, Release Train 2.2.0
    • setLabelBehavior

      public void setLabelBehavior(String labelBehavior)
      The label behavior for this sort option. If SortSettings.Labels.SINGLE, then the label should be used for both ascending and descending sort options. If SortSettings.Labels.PER_OPTION, then ascendingLabel and descendingLabel should be used.
      Since:
      Search Service 2.1.4, Release Train 2.1.4, Search Service 2.2.0, Release Train 2.2.0
    • setName

      public void setName(String name)
      Name to use to identify the sort option. Typically, this should correspond to a FieldDefinition.getAbbreviation().
      Parameters:
      name - Name to use to identify the sort option.
    • setField

      public void setField(FieldRef field)
      The field to be sorted on. Only id, indexableType, and label are serialized in API responses.
      Parameters:
      field - field to be sorted on
    • setVariantType

      public void setVariantType(String variantType)
      The field variant type which should be sorted on.
    • setDisplayOrder

      public void setDisplayOrder(Integer displayOrder)
      The display order of this sort option
      Parameters:
      displayOrder - the order to display this sort option
    • setAttributes

      public void setAttributes(Map<String,Object> attributes)
      Miscellaneous attributes for this sort option.
      Parameters:
      attributes - Miscellaneous attributes for this sort option.
    • setContextState

      public void setContextState(com.broadleafcommerce.data.tracking.core.filtering.business.domain.ContextState contextState)
      A subset of Tracking information to expose the context state for this object.
      Specified by:
      setContextState in interface com.broadleafcommerce.data.tracking.core.ContextStateAware
      Parameters:
      contextState - a subset of Tracking information to expose the context state for this object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • canEqual

      protected boolean canEqual(Object other)
    • hashCode

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

      public String toString()
      Overrides:
      toString in class Object