T
- type of the resourceV
- type of the valuepublic final class RangeTermFilterSearchModel<T,V extends Comparable<? super V>> extends Base
Modifier and Type | Field and Description |
---|---|
protected SearchModel<T> |
searchModel |
protected Function<V,String> |
typeSerializer |
Modifier and Type | Method and Description |
---|---|
List<FilterExpression<T>> |
containsAll(Iterable<V> values)
Generates an expression to select all elements with attributes matching all the given values.
|
List<FilterExpression<T>> |
containsAllAsString(Iterable<String> values)
Generates an expression to select all elements with attributes matching all the given values.
|
List<FilterExpression<T>> |
containsAny(Iterable<V> values)
Generates an expression to select all elements with attributes matching any of the given values.
|
List<FilterExpression<T>> |
containsAnyAsString(Iterable<String> values)
Generates an expression to select all elements with attributes matching any of the given values.
|
List<FilterExpression<T>> |
exists()
Creates filters for a field that contains at least one value.
|
SearchModel<T> |
getSearchModel()
The search model for the filter.
|
List<FilterExpression<T>> |
is(V value)
Generates an expression to select all elements with the given attribute value.
|
List<FilterExpression<T>> |
isBetween(FilterRange<V> range)
Generates an expression to select all elements with an attribute value within the given range.
|
List<FilterExpression<T>> |
isBetween(V lowerEndpoint,
V upperEndpoint)
Generates an expression to select all elements with an attribute value within the range defined by the given endpoints.
|
List<FilterExpression<T>> |
isBetweenAll(Iterable<FilterRange<V>> filterRanges)
Generates an expression to select all elements with an attribute value within all the given ranges.
|
List<FilterExpression<T>> |
isBetweenAllAsString(Iterable<FilterRange<String>> ranges)
Generates an expression to select all elements with an attribute value within all the given ranges.
|
List<FilterExpression<T>> |
isBetweenAny(Iterable<FilterRange<V>> filterRanges)
Generates an expression to select all elements with an attribute value within any of the given ranges.
|
List<FilterExpression<T>> |
isBetweenAnyAsString(Iterable<FilterRange<String>> ranges)
Generates an expression to select all elements with an attribute value within any of the given ranges.
|
List<FilterExpression<T>> |
isBetweenAsString(FilterRange<String> range)
Generates an expression to select all elements with an attribute value within the given range.
|
List<FilterExpression<T>> |
isGreaterThanOrEqualTo(V value)
Generates an expression to select all elements with an attribute value greater than or equal to the given value.
|
List<FilterExpression<T>> |
isIn(Iterable<V> values)
Generates an expression to select all elements with attributes matching any of the given values.
|
List<FilterExpression<T>> |
isLessThanOrEqualTo(V value)
Generates an expression to select all elements with an attribute value less than or equal to the given value.
|
List<FilterExpression<T>> |
missing()
Creates filters for fields that contain no values.
|
static <T,V extends Comparable<? super V>> |
of(String attributePath,
Function<V,String> typeSerializer)
Creates an instance of the search model to generate range and term filter expressions.
|
protected final SearchModel<T> searchModel
public List<FilterExpression<T>> is(V value)
is
in interface FilterSearchModel<T,V extends Comparable<? super V>>
value
- the value to filter bypublic List<FilterExpression<T>> isIn(Iterable<V> values)
Alias for FilterSearchModel.containsAny(Iterable)
.
values
- the values to filter bypublic List<FilterExpression<T>> containsAny(Iterable<V> values)
containsAny
in interface FilterSearchModel<T,V extends Comparable<? super V>>
values
- the values to filter bypublic List<FilterExpression<T>> containsAll(Iterable<V> values)
containsAll
in interface FilterSearchModel<T,V extends Comparable<? super V>>
values
- the values to filter bypublic List<FilterExpression<T>> isBetween(FilterRange<V> range)
range
- the range of values to filter bypublic List<FilterExpression<T>> isBetween(V lowerEndpoint, V upperEndpoint)
lowerEndpoint
- the lower endpoint of the range of values to filter by, inclusiveupperEndpoint
- the upper endpoint of the range of values to filter by, inclusivepublic List<FilterExpression<T>> isBetweenAny(Iterable<FilterRange<V>> filterRanges)
filterRanges
- the ranges of values to filter bypublic List<FilterExpression<T>> isBetweenAll(Iterable<FilterRange<V>> filterRanges)
filterRanges
- the ranges of values to filter bypublic List<FilterExpression<T>> isGreaterThanOrEqualTo(V value)
value
- the lower endpoint of the range [v, +∞)public List<FilterExpression<T>> isLessThanOrEqualTo(V value)
value
- the upper endpoint of the range (-∞, v]public static <T,V extends Comparable<? super V>> RangeTermFilterSearchModel<T,V> of(String attributePath, Function<V,String> typeSerializer)
T
- type of the resourceV
- type of the valueattributePath
- the path of the attribute as expected by Composable Commerce (e.g. "variants.attributes.color.key")typeSerializer
- the function to convert the provided value to a string accepted by Composable Commercepublic List<FilterExpression<T>> isBetweenAsString(FilterRange<String> range)
range
- the range of values (as string) to filter bypublic List<FilterExpression<T>> isBetweenAnyAsString(Iterable<FilterRange<String>> ranges)
ranges
- the ranges of values (as string) to filter bypublic List<FilterExpression<T>> isBetweenAllAsString(Iterable<FilterRange<String>> ranges)
ranges
- the ranges of values (as string) to filter bypublic SearchModel<T> getSearchModel()
FilterSearchModel
getSearchModel
in interface FilterSearchModel<T,V>
public List<FilterExpression<T>> exists()
ExistsFilterSearchModelSupport
withCategory(client(), category -> { withProduct(client(), builder -> builder.categories(singleton(category.toReference())), productWithCategories -> { withProduct(client(), productWithoutCategories -> { final List<String> productIds = asList(productWithCategories.getId(), productWithoutCategories.getId()); final ProductProjectionSearch exists = ProductProjectionSearch.ofStaged() .withQueryFilters(m -> m.id().isIn(productIds))//for test isolation .plusQueryFilters(m -> m.categories().exists()); assertEventually(() -> { final List<ProductProjection> results = client().executeBlocking(exists).getResults(); assertThat(results) .hasSize(1) .extracting(s -> s.getId()) .containsExactly(productWithCategories.getId()) .doesNotContain(productWithoutCategories.getId()); }); }); }); });
See the test code.
exists
in interface ExistsAndMissingFilterSearchModelSupport<T>
exists
in interface ExistsFilterSearchModelSupport<T>
public List<FilterExpression<T>> missing()
MissingFilterSearchModelSupport
withCategory(client(), category -> { withProduct(client(), builder -> builder.categories(singleton(category.toReference())), productWithCategories -> { withProduct(client(), productWithoutCategories -> { final List<String> productIds = asList(productWithCategories.getId(), productWithoutCategories.getId()); final ProductProjectionSearch missing = ProductProjectionSearch.ofStaged() .withQueryFilters(m -> m.id().isIn(productIds))//for test isolation .plusQueryFilters(m -> m.categories().missing()); assertEventually(() -> { final List<ProductProjection> results = client().executeBlocking(missing).getResults(); assertThat(results) .hasSize(1) .extracting(s -> s.getId()) .containsExactly(productWithoutCategories.getId()) .doesNotContain(productWithCategories.getId()); }); }); }); });
See the test code.
missing
in interface ExistsAndMissingFilterSearchModelSupport<T>
missing
in interface MissingFilterSearchModelSupport<T>
public List<FilterExpression<T>> containsAnyAsString(Iterable<String> values)
containsAnyAsString
in interface FilterSearchModel<T,V>
values
- the values to filter bypublic List<FilterExpression<T>> containsAllAsString(Iterable<String> values)
containsAllAsString
in interface FilterSearchModel<T,V>
values
- the values to filter by