public interface ReferenceExpansionDsl<T,C> extends ReferenceExpansionSupport<T>
Modifier and Type | Method and Description |
---|---|
C |
plusExpansionPaths(ExpansionPath<T> expansionPath)
Creates a new object with the properties of the old object but adds
expansionPath to the expansion paths. |
default C |
plusExpansionPaths(ExpansionPathContainer<T> holder) |
C |
plusExpansionPaths(List<ExpansionPath<T>> expansionPaths)
Creates a new object with the properties of the old object but adds
expansionPaths to the expansion paths. |
C |
plusExpansionPaths(String expansionPath)
Creates a new object with the properties of the old object but adds
expansionPath to the expansion paths. |
C |
withExpansionPaths(ExpansionPath<T> expansionPath)
Creates a new object with the properties of the old object but replaces all expansion paths with a single
expansionPath . |
default C |
withExpansionPaths(ExpansionPathContainer<T> holder) |
C |
withExpansionPaths(List<ExpansionPath<T>> expansionPaths)
Creates a new object with the properties of the old object but replaces all expansion paths with
expansionPaths . |
C |
withExpansionPaths(String expansionPath)
Creates a new object with the properties of the old object but replaces all expansion paths with a single
expansionPath . |
expansionPaths
C withExpansionPaths(List<ExpansionPath<T>> expansionPaths)
expansionPaths
.expansionPaths
- the new expansion pathsC withExpansionPaths(ExpansionPath<T> expansionPath)
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.
expansionPath
- the new expansion pathsC withExpansionPaths(String expansionPath)
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.
expansionPath
- the new expansion pathsC plusExpansionPaths(List<ExpansionPath<T>> expansionPaths)
expansionPaths
to the expansion paths.expansionPaths
- the new expansion paths to add to the existing onesC plusExpansionPaths(ExpansionPath<T> expansionPath)
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.
expansionPath
- the new expansion path to add to the existing onesC plusExpansionPaths(String expansionPath)
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.
expansionPath
- the new expansion path to add to the existing onesdefault C withExpansionPaths(ExpansionPathContainer<T> holder)
default C plusExpansionPaths(ExpansionPathContainer<T> holder)