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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
boolean
The "Ascending" label of this search option.Miscellaneous attributes for this sort option.com.broadleafcommerce.data.tracking.core.filtering.business.domain.ContextState
A subset ofTracking
information to expose the context state for this object.The "Descending" label of this search option.Returns a display label for this sort option.The display order of this sort optiongetField()
The field to be sorted on.getId()
The context ID of the sort option.getLabel()
The label of this sort option.getName()
Name to use to identify the sort option.The field variant type which should be sorted on.int
hashCode()
void
setAscendingLabel
(String ascendingLabel) The "Ascending" label of this search option.void
setAttributes
(Map<String, Object> attributes) Miscellaneous attributes for this sort option.void
setContextState
(com.broadleafcommerce.data.tracking.core.filtering.business.domain.ContextState contextState) A subset ofTracking
information to expose the context state for this object.void
setDescendingLabel
(String descendingLabel) The "Descending" label of this search option.void
setDisplayOrder
(Integer displayOrder) The display order of this sort optionvoid
The field to be sorted on.void
The context ID of the sort option.void
The label of this sort option.void
setLabelBehavior
(String labelBehavior) The label behavior for this sort option.void
Name to use to identify the sort option.void
setSortBehavior
(String sortBehavior) The sorting behavior of this sort option.void
setVariantType
(String variantType) The field variant type which should be sorted on.toString()
-
Constructor Details
-
SortOption
public SortOption()
-
-
Method Details
-
getFieldDefinitionId
-
getFieldIndexableType
-
getSortBehavior
-
getLabelBehavior
-
getDisplayLabel
Returns a display label for this sort option. This is only used for display purposes in a grid. -
getId
The context ID of the sort option.- Returns:
- the context ID of the sort option
-
getLabel
The label of this sort option. This is the label that may be displayed to the user when thesort behavior
isdefault
and alabel behavior
ofSortSettings.Labels.SINGLE
. -
getAscendingLabel
The "Ascending" label of this search option. Should be used if thesort behavior
isascending only
ordefault
.- Since:
- Search Service 2.1.4, Release Train 2.1.4, Search Service 2.2.0, Release Train 2.2.0
-
getDescendingLabel
The "Descending" label of this search option. Should be used if thesort behavior
isdescending only
ordefault
.- Since:
- Search Service 2.1.4, Release Train 2.1.4, Search Service 2.2.0, Release Train 2.2.0
-
getName
Name to use to identify the sort option. Typically, this should correspond to aFieldDefinition.getAbbreviation()
.- Returns:
- Name to use to identify the sort option.
-
getField
The field to be sorted on. Onlyid
,indexableType
, andlabel
are serialized in API responses.- Returns:
- field to be sorted on
-
getVariantType
The field variant type which should be sorted on. -
getDisplayOrder
The display order of this sort option- Returns:
- the order to display this sort option
-
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 ofTracking
information to expose the context state for this object.- Specified by:
getContextState
in interfacecom.broadleafcommerce.data.tracking.core.ContextStateAware
- Returns:
- a subset of
Tracking
information to expose the context state for this object
-
setId
The context ID of the sort option.- Parameters:
id
- the context ID of the sort option
-
setLabel
The label of this sort option. This is the label that may be displayed to the user when thesort behavior
isdefault
and alabel behavior
ofSortSettings.Labels.SINGLE
. -
setAscendingLabel
The "Ascending" label of this search option. Should be used if thesort behavior
isascending only
ordefault
.- Since:
- Search Service 2.1.4, Release Train 2.1.4, Search Service 2.2.0, Release Train 2.2.0
-
setDescendingLabel
The "Descending" label of this search option. Should be used if thesort behavior
isdescending only
ordefault
.- Since:
- Search Service 2.1.4, Release Train 2.1.4, Search Service 2.2.0, Release Train 2.2.0
-
setSortBehavior
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.
- Since:
- Search Service 2.1.4, Release Train 2.1.4, Search Service 2.2.0, Release Train 2.2.0
-
setLabelBehavior
The label behavior for this sort option. IfSortSettings.Labels.SINGLE
, then thelabel
should be used for both ascending and descending sort options. IfSortSettings.Labels.PER_OPTION
, thenascendingLabel
anddescendingLabel
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
Name to use to identify the sort option. Typically, this should correspond to aFieldDefinition.getAbbreviation()
.- Parameters:
name
- Name to use to identify the sort option.
-
setField
The field to be sorted on. Onlyid
,indexableType
, andlabel
are serialized in API responses.- Parameters:
field
- field to be sorted on
-
setVariantType
The field variant type which should be sorted on. -
setDisplayOrder
The display order of this sort option- Parameters:
displayOrder
- the order to display this sort option
-
setAttributes
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 ofTracking
information to expose the context state for this object.- Specified by:
setContextState
in interfacecom.broadleafcommerce.data.tracking.core.ContextStateAware
- Parameters:
contextState
- a subset ofTracking
information to expose the context state for this object
-
equals
-
canEqual
-
hashCode
public int hashCode() -
toString
-