public interface ProductProjectionByKeyGet extends MetaModelGetDsl<ProductProjection,ProductProjection,ProductProjectionByKeyGet,ProductProjectionExpansionModel<ProductProjection>>, PriceSelectionRequestDsl<ProductProjectionByKeyGet>, LocaleSelectionRequestDsl<ProductProjectionByKeyGet>, StoreSelectionRequestDsl<ProductProjectionByKeyGet>
final String key = randomKey(); ProductFixtures.withProduct(client(), builder -> builder.key(key), product -> { final ProductProjectionByKeyGet request = ProductProjectionByKeyGet.ofStaged(key); final ProductProjection productProjection = client().executeBlocking(request); assertThat(productProjection.getId()).isEqualTo(product.getId()); });
See the test code.
Modifier and Type | Method and Description |
---|---|
List<ExpansionPath<ProductProjection>> |
expansionPaths() |
static ProductProjectionByKeyGet |
of(String key,
ProductProjectionType projectionType) |
static ProductProjectionByKeyGet |
ofCurrent(String key) |
static ProductProjectionByKeyGet |
ofStaged(String key) |
ProductProjectionByKeyGet |
plusExpansionPaths(ExpansionPath<ProductProjection> expansionPath)
Creates a new object with the properties of the old object but adds
expansionPath to the expansion paths. |
ProductProjectionByKeyGet |
withExpansionPaths(ExpansionPath<ProductProjection> expansionPath)
Creates a new object with the properties of the old object but replaces all expansion paths with a single
expansionPath . |
ProductProjectionByKeyGet |
withExpansionPaths(List<ExpansionPath<ProductProjection>> expansionPaths)
Creates a new object with the properties of the old object but replaces all expansion paths with
expansionPaths . |
deserialize
canDeserialize, httpRequestIntent
plusExpansionPaths, withExpansionPaths
plusExpansionPaths, plusExpansionPaths, plusExpansionPaths, withExpansionPaths, withExpansionPaths
getPriceSelection, withPriceSelection
getLocaleSelection, withLocaleSelection
getStoreSelection, withStoreSelection
static ProductProjectionByKeyGet ofStaged(String key)
static ProductProjectionByKeyGet ofCurrent(String key)
static ProductProjectionByKeyGet of(String key, ProductProjectionType projectionType)
List<ExpansionPath<ProductProjection>> expansionPaths()
expansionPaths
in interface ExpansionPathContainer<ProductProjection>
expansionPaths
in interface ReferenceExpansionSupport<ProductProjection>
ProductProjectionByKeyGet plusExpansionPaths(ExpansionPath<ProductProjection> expansionPath)
ReferenceExpansionDsl
expansionPath
to the expansion paths.
An example in the product projection context:
final ProductProjectionByIdGet fetch = ProductProjectionByIdGet.of("id", ProductProjectionType.CURRENT); assertThat(fetch.expansionPaths()).isEmpty(); final ProductProjectionByIdGet fetch2 = fetch.plusExpansionPaths(ProductProjectionExpansionModel.of().categories()); assertThat(fetch.expansionPaths()).overridingErrorMessage("old object is unchanged").isEmpty(); assertThat(fetch2.expansionPaths()).isEqualTo(asList(ExpansionPath.of("categories[*]"))); assertThat(fetch2).isNotSameAs(fetch);
See the test code.
plusExpansionPaths
in interface ReferenceExpansionDsl<ProductProjection,ProductProjectionByKeyGet>
expansionPath
- the new expansion path to add to the existing onesProductProjectionByKeyGet withExpansionPaths(ExpansionPath<ProductProjection> expansionPath)
ReferenceExpansionDsl
expansionPath
.
An example in the product projection context:
final ProductProjectionByIdGet fetch = ProductProjectionByIdGet.of("id", ProductProjectionType.CURRENT) .withExpansionPaths(ProductProjectionExpansionModel.of().categories()); assertThat(fetch.expansionPaths()) .isEqualTo(asList(ExpansionPath.of("categories[*]"))); final ProductProjectionByIdGet fetch2 = fetch.withExpansionPaths(ProductProjectionExpansionModel.of().productType()); assertThat(fetch.expansionPaths()).overridingErrorMessage("old object is unchanged") .isEqualTo(asList(ExpansionPath.of("categories[*]"))); assertThat(fetch2.expansionPaths()).isEqualTo(asList(ExpansionPath.of("productType"))); assertThat(fetch2).isNotSameAs(fetch);
See the test code.
This method also can be used to use the same expansions as in another request:
final ProductProjectionQuery query = ProductProjectionQuery.ofCurrent().withExpansionPaths(m -> m.categories()); final ProductProjectionSearch search = ProductProjectionSearch.ofCurrent().withExpansionPaths(query); assertThat(query.expansionPaths()) .hasSize(1) .as("reuse expansion spec from other request") .isEqualTo(search.expansionPaths());
See the test code.
withExpansionPaths
in interface ReferenceExpansionDsl<ProductProjection,ProductProjectionByKeyGet>
expansionPath
- the new expansion pathsProductProjectionByKeyGet withExpansionPaths(List<ExpansionPath<ProductProjection>> expansionPaths)
ReferenceExpansionDsl
expansionPaths
.withExpansionPaths
in interface ReferenceExpansionDsl<ProductProjection,ProductProjectionByKeyGet>
expansionPaths
- the new expansion paths