public class Facets extends Object
Example:
Facets f = new Facets("color", "yellow", "blue").add("brand", "nike"); // f.toString() is: brand:nike,color:blue|yellow ArgMap panelArguments = new ArgMap(); panelArguments.put("facets", f); // ... other arguments...If it is convenient in your scenario you can serialize the current selected values using
toString()
and store them in the browser. When a check-box is clicked, deserialize it afterwards like this:
Facets f = Facets.parse(facetsString);Then update it with the last click and send a new request:
f = f.toggle(clickedAttribute, clickedValue); panelArguments.put("facets", f); // ... add other arguments and send request...Note that Facets are immutable and all methods return new Facets objects.
Constructor | Description |
---|---|
Facets() |
Create a new empty Facets.
|
Facets(String attribute,
String... values) |
Create a new Facets with the given attribute and values.
|
Facets(String attribute,
List<String> values) |
Create a new Facets with the given attribute and values.
|
Modifier and Type | Method | Description |
---|---|---|
Facets |
add(String attribute,
String... values) |
Return a new Facets with the given attribute and values added.
|
Facets |
add(String attribute,
List<String> values) |
Return a new Facets with the given attribute and values added.
|
Facets |
addRange(String attribute,
String min,
String max) |
Return a new Facets with the given attribute range added.
|
boolean |
equals(Object obj) |
|
int |
hashCode() |
|
static Facets |
parse(String source) |
Create a Facets object from the source string.
|
Facets |
remove(String attribute) |
Return a new Facets where the given attribute is removed.
|
Facets |
toggle(String attribute,
String value) |
Toggle the given attribute and value.
|
String |
toString() |
Builds and returns a string on the facet argument format.
|
public Facets()
public Facets(String attribute, String... values)
attribute
- the attribute for the facet.values
- the values for the attribute.IllegalArgumentException
- if attribute is null or the empty string.public Facets(String attribute, List<String> values)
attribute
- the attribute for the facet.values
- the values for the attribute.IllegalArgumentException
- if attribute is null or the empty string.public Facets add(String attribute, String... values)
attribute
- the attribute.values
- the values for the attribute.IllegalArgumentException
- if attribute is null or the empty string.public Facets add(String attribute, List<String> values)
attribute
- the attribute.values
- the values for the attribute.IllegalArgumentException
- if attribute is null or the empty string.public Facets toggle(String attribute, String value)
attribute
- the attribute.value
- the value for the attribute to be toggled.IllegalArgumentException
- if attribute is null or the empty string.public Facets addRange(String attribute, String min, String max)
attribute
- the attribute.min
- min value, inclusive.max
- max value, inclusive.IllegalArgumentException
- if attribute is null or the empty string.public Facets remove(String attribute)
attribute
- attribute to remove.IllegalArgumentException
- if attribute is null or the empty string.public static Facets parse(String source)
source
- the string to parseIllegalArgumentException
- if there are any parse errorspublic String toString()
Copyright © 2020 Apptus Technologies AB. All rights reserved.