public interface CartDiscountByKeyGet extends MetaModelGetDsl<CartDiscount,CartDiscount,CartDiscountByKeyGet,CartDiscountExpansionModel<CartDiscount>>
CartDiscount by a known key.
CartDiscountFixtures.withCartDiscount(client(), cartDiscount -> { final CartDiscount cd = client().executeBlocking(CartDiscountByKeyGet.of(cartDiscount.getKey())); Assertions.assertThat(cd).isNotNull(); Assertions.assertThat(cd.getKey()).isEqualTo(cartDiscount.getKey()); return cartDiscount; });See the test code.
| Modifier and Type | Method and Description |
|---|---|
List<ExpansionPath<CartDiscount>> |
expansionPaths() |
static CartDiscountByKeyGet |
of(String key) |
CartDiscountByKeyGet |
plusExpansionPaths(ExpansionPath<CartDiscount> expansionPath)
Creates a new object with the properties of the old object but adds
expansionPath to the expansion paths. |
CartDiscountByKeyGet |
withExpansionPaths(ExpansionPath<CartDiscount> expansionPath)
Creates a new object with the properties of the old object but replaces all expansion paths with a single
expansionPath. |
CartDiscountByKeyGet |
withExpansionPaths(List<ExpansionPath<CartDiscount>> expansionPaths)
Creates a new object with the properties of the old object but replaces all expansion paths with
expansionPaths. |
deserializecanDeserialize, httpRequestIntentplusExpansionPaths, withExpansionPathsplusExpansionPaths, plusExpansionPaths, plusExpansionPaths, withExpansionPaths, withExpansionPathsstatic CartDiscountByKeyGet of(String key)
List<ExpansionPath<CartDiscount>> expansionPaths()
expansionPaths in interface ExpansionPathContainer<CartDiscount>expansionPaths in interface ReferenceExpansionSupport<CartDiscount>CartDiscountByKeyGet plusExpansionPaths(ExpansionPath<CartDiscount> expansionPath)
ReferenceExpansionDslexpansionPath 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<CartDiscount,CartDiscountByKeyGet>expansionPath - the new expansion path to add to the existing onesCartDiscountByKeyGet withExpansionPaths(ExpansionPath<CartDiscount> expansionPath)
ReferenceExpansionDslexpansionPath.
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<CartDiscount,CartDiscountByKeyGet>expansionPath - the new expansion pathsCartDiscountByKeyGet withExpansionPaths(List<ExpansionPath<CartDiscount>> expansionPaths)
ReferenceExpansionDslexpansionPaths.withExpansionPaths in interface ReferenceExpansionDsl<CartDiscount,CartDiscountByKeyGet>expansionPaths - the new expansion paths