Class Facet
- java.lang.Object
-
- com.funnelback.publicui.search.model.transaction.Facet
-
- Direct Known Subclasses:
FacetConverter.FacetWithFields
@XStreamConverter(FacetConverter.class) public class Facet extends Object
Facets, generated from the result data (Metadata counts, GScope counts, URL counts).
- Since:
- 11.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Facet.CategoryValue
Value of a facet category, such as "Location = Sydney".
-
Field Summary
Fields Modifier and Type Field Description private List<Facet.CategoryValue>
allValues
private @NotNull @NonNull FacetConstraintJoin
constraintJoin
private Comparator<Facet.CategoryValue>
customComparator
If non-null this comparator will be used to sort values returned by thegetAllValues()
,getSelectedValues()
andFacet#getUnselectedValues()
methods.private Map<String,Object>
customData
Custom data placeholder allowing any arbitrary data to be stored for this facet by hook scripts.private @NotNull @NonNull FacetValues
facetValues
private @NotNull @NonNull FacetDisplayType
guessedDisplayType
The guessed type of the facet based on its configuration.private String
name
Facet name, for example "Location"private @NotNull @NonNull List<FacetValuesOrder>
order
private @NotNull @NonNull FacetSelectionType
selectionType
private String
unselectAllUrl
URL to use to unselect all possible values of this facet, built from the current URL
-
Constructor Summary
Constructors Modifier Constructor Description Facet(String name)
Deprecated.Facet(String name, FacetSelectionType selectionType, FacetConstraintJoin constraintJoin, FacetValues facetValues, List<FacetValuesOrder> order)
protected
Facet(String name, String unselectAllUrl, @NonNull FacetSelectionType selectionType, @NonNull FacetConstraintJoin constraintJoin, @NonNull List<FacetValuesOrder> order, @NonNull FacetValues facetValues, @NonNull FacetDisplayType guessedDisplayType, Comparator<Facet.CategoryValue> customComparator)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description List<Facet.CategoryValue>
getAllValues()
@NonNull FacetConstraintJoin
getConstraintJoin()
Comparator<Facet.CategoryValue>
getCustomComparator()
If non-null this comparator will be used to sort values returned by thegetAllValues()
,getSelectedValues()
andFacet#getUnselectedValues()
methods.Map<String,Object>
getCustomData()
Custom data placeholder allowing any arbitrary data to be stored for this facet by hook scripts.@NonNull FacetValues
getFacetValues()
@NonNull FacetDisplayType
getGuessedDisplayType()
The guessed type of the facet based on its configuration.String
getName()
Facet name, for example "Location"@NonNull List<FacetValuesOrder>
getOrder()
List<Facet.CategoryValue>
getSelectedValues()
@NonNull FacetSelectionType
getSelectionType()
String
getUnselectAllUrl()
URL to use to unselect all possible values of this facet, built from the current URLboolean
hasValues()
Recursively check if this facet has any value at all.boolean
isSelected()
static <T> Stream<T>
ofNullableSingle(T a)
Clone from com.funnelback.common.function.StreamUtils.ofNullableSingle(T)void
setCustomComparator(Comparator<Facet.CategoryValue> customComparator)
If non-null this comparator will be used to sort values returned by thegetAllValues()
,getSelectedValues()
andFacet#getUnselectedValues()
methods.void
setName(String name)
Facet name, for example "Location"void
setOrder(@NonNull List<FacetValuesOrder> order)
void
setUnselectAllUrl(String unselectAllUrl)
URL to use to unselect all possible values of this facet, built from the current URLString
toString()
-
-
-
Field Detail
-
name
private String name
Facet name, for example "Location"
-
unselectAllUrl
private String unselectAllUrl
URL to use to unselect all possible values of this facet, built from the current URLThe URL is one where the facet is not selected, the URL may be used as the base URL to append to to select values within the facet.
-
customData
private final Map<String,Object> customData
Custom data placeholder allowing any arbitrary data to be stored for this facet by hook scripts.
-
selectionType
@NotNull @NonNull private @NotNull @NonNull FacetSelectionType selectionType
- Since:
- 15.12
-
constraintJoin
@NotNull @NonNull private @NotNull @NonNull FacetConstraintJoin constraintJoin
- Since:
- 15.12
-
order
@NotNull @NonNull private @NotNull @NonNull List<FacetValuesOrder> order
- Since:
- 15.12
-
facetValues
@NotNull @NonNull private @NotNull @NonNull FacetValues facetValues
- Since:
- 15.12
-
guessedDisplayType
@NotNull @NonNull private @NotNull @NonNull FacetDisplayType guessedDisplayType
The guessed type of the facet based on its configuration.This value can give an indication of how the facet should be displayed, for example SINGLE select where values come from a UNSCOPED query would give the value RADIO_BUTTON. The UI could use this to show the facets as radio buttons.
If the guessedType is not the way you intend to show the facet you should ignore this value and instead use the facet name or other fields which describe the facet to work out what should be shown i.e. don't have code which is if(guessedType == TAB) then show the facet as checkboxes.
Newer versions of Funnelback may change how the type is guessed.
- Since:
- 15.12
-
customComparator
private Comparator<Facet.CategoryValue> customComparator
If non-null this comparator will be used to sort values returned by thegetAllValues()
,getSelectedValues()
andFacet#getUnselectedValues()
methods.This currently does not sort the values returned by any other method such as the values in what is returned by
Facet#getCategories()
although this may change.- Since:
- 15.12
-
allValues
private final List<Facet.CategoryValue> allValues
-
-
Constructor Detail
-
Facet
public Facet(String name, FacetSelectionType selectionType, FacetConstraintJoin constraintJoin, FacetValues facetValues, List<FacetValuesOrder> order)
-
Facet
@Deprecated public Facet(String name)
Deprecated.Backwards compatible constructor so the stencils facet will continue to work.- Parameters:
name
-
-
Facet
protected Facet(String name, String unselectAllUrl, @NonNull @NonNull FacetSelectionType selectionType, @NonNull @NonNull FacetConstraintJoin constraintJoin, @NonNull @NonNull List<FacetValuesOrder> order, @NonNull @NonNull FacetValues facetValues, @NonNull @NonNull FacetDisplayType guessedDisplayType, Comparator<Facet.CategoryValue> customComparator)
-
-
Method Detail
-
getSelectedValues
public List<Facet.CategoryValue> getSelectedValues()
- Returns:
- List of selected values, useful to build breadcrumbs
-
hasValues
public boolean hasValues()
Recursively check if this facet has any value at all.- Returns:
- true if the facet possess at least one value.
-
ofNullableSingle
public static <T> Stream<T> ofNullableSingle(T a)
Clone from com.funnelback.common.function.StreamUtils.ofNullableSingle(T)- Type Parameters:
T
-- Parameters:
a
-- Returns:
-
isSelected
public boolean isSelected()
- Returns:
- True if any of the values of this facet is selected
-
getName
public String getName()
Facet name, for example "Location"
-
setName
public void setName(String name)
Facet name, for example "Location"
-
getUnselectAllUrl
public String getUnselectAllUrl()
URL to use to unselect all possible values of this facet, built from the current URLThe URL is one where the facet is not selected, the URL may be used as the base URL to append to to select values within the facet.
-
setUnselectAllUrl
public void setUnselectAllUrl(String unselectAllUrl)
URL to use to unselect all possible values of this facet, built from the current URLThe URL is one where the facet is not selected, the URL may be used as the base URL to append to to select values within the facet.
-
getCustomData
public Map<String,Object> getCustomData()
Custom data placeholder allowing any arbitrary data to be stored for this facet by hook scripts.
-
getSelectionType
@NonNull public @NonNull FacetSelectionType getSelectionType()
- Since:
- 15.12
-
getConstraintJoin
@NonNull public @NonNull FacetConstraintJoin getConstraintJoin()
- Since:
- 15.12
-
getOrder
@NonNull public @NonNull List<FacetValuesOrder> getOrder()
- Since:
- 15.12
-
setOrder
public void setOrder(@NonNull @NonNull List<FacetValuesOrder> order)
- Since:
- 15.12
-
getFacetValues
@NonNull public @NonNull FacetValues getFacetValues()
- Since:
- 15.12
-
getGuessedDisplayType
@NonNull public @NonNull FacetDisplayType getGuessedDisplayType()
The guessed type of the facet based on its configuration.This value can give an indication of how the facet should be displayed, for example SINGLE select where values come from a UNSCOPED query would give the value RADIO_BUTTON. The UI could use this to show the facets as radio buttons.
If the guessedType is not the way you intend to show the facet you should ignore this value and instead use the facet name or other fields which describe the facet to work out what should be shown i.e. don't have code which is if(guessedType == TAB) then show the facet as checkboxes.
Newer versions of Funnelback may change how the type is guessed.
- Since:
- 15.12
-
getCustomComparator
public Comparator<Facet.CategoryValue> getCustomComparator()
If non-null this comparator will be used to sort values returned by thegetAllValues()
,getSelectedValues()
andFacet#getUnselectedValues()
methods.This currently does not sort the values returned by any other method such as the values in what is returned by
Facet#getCategories()
although this may change.- Since:
- 15.12
-
setCustomComparator
public void setCustomComparator(Comparator<Facet.CategoryValue> customComparator)
If non-null this comparator will be used to sort values returned by thegetAllValues()
,getSelectedValues()
andFacet#getUnselectedValues()
methods.This currently does not sort the values returned by any other method such as the values in what is returned by
Facet#getCategories()
although this may change.- Since:
- 15.12
-
getAllValues
public List<Facet.CategoryValue> getAllValues()
- Returns:
- List of all facet values both selected and unselected.
-
-