T
- type of the resourceV
- type of the valuepublic class TermFilterSearchModelImpl<T,V> extends Base implements TermFilterExistsAndMissingSearchModel<T,V>
Modifier and Type | Field and Description |
---|---|
protected SearchModel<T> |
searchModel |
protected Function<V,String> |
typeSerializer |
Constructor and Description |
---|
TermFilterSearchModelImpl(SearchModel<T> searchModel,
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>> |
isIn(Iterable<V> values)
Generates an expression to select all elements with attributes matching any of the given values.
|
List<FilterExpression<T>> |
missing()
Creates filters for fields that contain no values.
|
static <T,V> TermFilterSearchModelImpl<T,V> |
of(String attributePath,
Function<V,String> typeSerializer)
Creates an instance of the search model to generate term filters.
|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
containsAllAsString, containsAnyAsString
getSearchModel
exists, missing
protected final SearchModel<T> searchModel
public TermFilterSearchModelImpl(SearchModel<T> searchModel, Function<V,String> typeSerializer)
public List<FilterExpression<T>> is(V value)
is
in interface FilterSearchModel<T,V>
is
in interface TermFilterExistsAndMissingSearchModel<T,V>
is
in interface TermFilterSearchModel<T,V>
value
- the value to filter bypublic List<FilterExpression<T>> isIn(Iterable<V> values)
Alias for FilterSearchModel.containsAny(Iterable)
.
isIn
in interface FilterSearchModel<T,V>
isIn
in interface TermFilterExistsAndMissingSearchModel<T,V>
isIn
in interface TermFilterSearchModel<T,V>
values
- the values to filter bypublic List<FilterExpression<T>> containsAny(Iterable<V> values)
containsAny
in interface FilterSearchModel<T,V>
containsAny
in interface TermFilterExistsAndMissingSearchModel<T,V>
containsAny
in interface TermFilterSearchModel<T,V>
values
- the values to filter bypublic List<FilterExpression<T>> containsAll(Iterable<V> values)
containsAll
in interface FilterSearchModel<T,V>
containsAll
in interface TermFilterExistsAndMissingSearchModel<T,V>
containsAll
in interface TermFilterSearchModel<T,V>
values
- the values to filter bypublic static <T,V> TermFilterSearchModelImpl<T,V> of(String attributePath, Function<V,String> typeSerializer)
of
in interface TermFilterExistsAndMissingSearchModel<T,V>
of
in interface TermFilterSearchModel<T,V>
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 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