T
- the type of the result of the commandC
- class which will serialized as JSON command body, most likely a templateE
- type of the expansion modelpublic class MetaModelUpdateCommandDslImpl<T extends ResourceView<T,T>,C extends UpdateCommandDsl<T,C>,E> extends CommandImpl<T> implements UpdateCommandDsl<T,C>, MetaModelExpansionDslExpansionModelRead<T,C,E>
Modifier | Constructor and Description |
---|---|
protected |
MetaModelUpdateCommandDslImpl(MetaModelUpdateCommandDslBuilder<T,C,E> builder) |
protected |
MetaModelUpdateCommandDslImpl(Versioned<T> versioned,
List<? extends UpdateAction<T>> updateActions,
JsonEndpoint<T> endpoint,
Function<MetaModelUpdateCommandDslBuilder<T,C,E>,C> creationFunction,
E expansionModel) |
Modifier and Type | Method and Description |
---|---|
protected List<NameValuePair> |
additionalHttpQueryParameters() |
protected MetaModelUpdateCommandDslBuilder<T,C,E> |
copyBuilder() |
E |
expansionModel() |
List<ExpansionPath<T>> |
expansionPaths() |
List<? extends UpdateAction<T>> |
getUpdateActions()
Gets the list of updates which should be applied to the object
|
Versioned<T> |
getVersioned() |
HttpRequestIntent |
httpRequestIntent()
Provides an http request intent, this does not include the execution of it.
|
protected com.fasterxml.jackson.databind.JavaType |
jacksonJavaType() |
C |
plusExpansionPaths(ExpansionPath<T> expansionPath)
Creates a new object with the properties of the old object but adds
expansionPath to the expansion paths. |
C |
plusExpansionPaths(Function<E,ExpansionPathContainer<T>> m)
Creates a new object with the properties of the old object but adds a new expansion path to it by using meta models.
|
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 |
plusUpdateActions(List<? extends UpdateAction<T>> updateActions)
Creates a copy of this update command with additional update actions.
|
protected C |
withAdditionalHttpQueryParameters(List<NameValuePair> pairs) |
C |
withAdditionalHttpQueryParameters(NameValuePair pair) |
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 . |
C |
withExpansionPaths(Function<E,ExpansionPathContainer<T>> m)
Creates a new object with the properties of the old object but replaces all expansion paths with a single
expansionPath by using meta models. |
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 . |
C |
withUpdateActions(List<? extends UpdateAction<T>> updateActions) |
C |
withVersion(Long version) |
C |
withVersion(Versioned<T> newVersioned)
Creates a copy of this update command with a different value for version.
|
deserialize
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
canDeserialize, deserialize
plusExpansionPaths, withExpansionPaths
protected MetaModelUpdateCommandDslImpl(Versioned<T> versioned, List<? extends UpdateAction<T>> updateActions, JsonEndpoint<T> endpoint, Function<MetaModelUpdateCommandDslBuilder<T,C,E>,C> creationFunction, E expansionModel)
protected MetaModelUpdateCommandDslImpl(MetaModelUpdateCommandDslBuilder<T,C,E> builder)
protected com.fasterxml.jackson.databind.JavaType jacksonJavaType()
jacksonJavaType
in class CommandImpl<T extends ResourceView<T,T>>
public HttpRequestIntent httpRequestIntent()
SphereRequest
httpRequestIntent
in interface SphereRequest<T extends ResourceView<T,T>>
public C withVersion(Versioned<T> newVersioned)
UpdateCommandDsl
withVersion
in interface UpdateCommandDsl<T extends ResourceView<T,T>,C extends UpdateCommandDsl<T,C>>
newVersioned
- the new versioned parameter which is expected to contain the most recent version of the resource, do not change the IDpublic C withVersion(Long version)
withVersion
in interface UpdateCommandDsl<T extends ResourceView<T,T>,C extends UpdateCommandDsl<T,C>>
public C withUpdateActions(List<? extends UpdateAction<T>> updateActions)
withUpdateActions
in interface UpdateCommandDsl<T extends ResourceView<T,T>,C extends UpdateCommandDsl<T,C>>
public C plusUpdateActions(List<? extends UpdateAction<T>> updateActions)
UpdateCommandDsl
plusUpdateActions
in interface UpdateCommandDsl<T extends ResourceView<T,T>,C extends UpdateCommandDsl<T,C>>
updateActions
- the new update actions to append to the update command.public List<? extends UpdateAction<T>> getUpdateActions()
UpdateCommand
getUpdateActions
in interface UpdateCommand<T extends ResourceView<T,T>>
protected MetaModelUpdateCommandDslBuilder<T,C,E> copyBuilder()
public List<ExpansionPath<T>> expansionPaths()
expansionPaths
in interface ExpansionPathContainer<T extends ResourceView<T,T>>
expansionPaths
in interface ReferenceExpansionSupport<T extends ResourceView<T,T>>
public final C withExpansionPaths(List<ExpansionPath<T>> expansionPaths)
ReferenceExpansionDsl
expansionPaths
.withExpansionPaths
in interface ReferenceExpansionDsl<T extends ResourceView<T,T>,C extends UpdateCommandDsl<T,C>>
expansionPaths
- the new expansion pathspublic C withExpansionPaths(ExpansionPath<T> 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<T extends ResourceView<T,T>,C extends UpdateCommandDsl<T,C>>
expansionPath
- the new expansion pathspublic C withExpansionPaths(Function<E,ExpansionPathContainer<T>> m)
MetaModelReferenceExpansionDsl
expansionPath
by using meta models.
An example in the product projection context:
final ProductProjectionByIdGet fetch = ProductProjectionByIdGet.of("id", ProductProjectionType.CURRENT) .plusExpansionPaths(ProductProjectionExpansionModel.of().categories()); assertThat(fetch.expansionPaths()) .isEqualTo(asList(ExpansionPath.of("categories[*]"))); final ProductProjectionByIdGet fetch2 = fetch.withExpansionPaths(m -> m.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.
withExpansionPaths
in interface MetaModelReferenceExpansionDsl<T extends ResourceView<T,T>,C extends UpdateCommandDsl<T,C>,E>
m
- function to use the meta model for expansions to create an expansion pathpublic C plusExpansionPaths(List<ExpansionPath<T>> expansionPaths)
ReferenceExpansionDsl
expansionPaths
to the expansion paths.plusExpansionPaths
in interface ReferenceExpansionDsl<T extends ResourceView<T,T>,C extends UpdateCommandDsl<T,C>>
expansionPaths
- the new expansion paths to add to the existing onespublic C plusExpansionPaths(ExpansionPath<T> 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<T extends ResourceView<T,T>,C extends UpdateCommandDsl<T,C>>
expansionPath
- the new expansion path to add to the existing onespublic C withExpansionPaths(String 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<T extends ResourceView<T,T>,C extends UpdateCommandDsl<T,C>>
expansionPath
- the new expansion pathspublic C plusExpansionPaths(String 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<T extends ResourceView<T,T>,C extends UpdateCommandDsl<T,C>>
expansionPath
- the new expansion path to add to the existing onespublic C plusExpansionPaths(Function<E,ExpansionPathContainer<T>> m)
MetaModelReferenceExpansionDsl
An example in the product projection context:
final ProductProjectionByIdGet fetch1 = ProductProjectionByIdGet.of("id", ProductProjectionType.CURRENT) .plusExpansionPaths(m -> m.categories()); assertThat(fetch1.expansionPaths()) .isEqualTo(asList(ExpansionPath.of("categories[*]"))); final ProductProjectionByIdGet fetch2 = fetch1.plusExpansionPaths(m -> m.productType()); assertThat(fetch2.expansionPaths()) .isEqualTo(asList(ExpansionPath.of("categories[*]"), ExpansionPath.of("productType"))) .isEqualTo(listOf(fetch1.expansionPaths(), ExpansionPath.of("productType"))); //this is equivalent to final ExpansionPath<ProductProjection> categoryExpand = ProductProjectionExpansionModel.of().categories().expansionPaths().get(0); final ExpansionPath<ProductProjection> productTypeExpand = ProductProjectionExpansionModel.of().productType().expansionPaths().get(0); final ProductProjectionByIdGet fetchB = ProductProjectionByIdGet.of("id", ProductProjectionType.CURRENT) .withExpansionPaths(asList(categoryExpand, productTypeExpand)); assertThat(fetchB.expansionPaths()) .isEqualTo(asList(ExpansionPath.of("categories[*]"), ExpansionPath.of("productType")));
See the test code.
plusExpansionPaths
in interface MetaModelReferenceExpansionDsl<T extends ResourceView<T,T>,C extends UpdateCommandDsl<T,C>,E>
m
- function to use the meta model for expansions to create an expansion pathpublic E expansionModel()
expansionModel
in interface MetaModelExpansionDslExpansionModelRead<T extends ResourceView<T,T>,C extends UpdateCommandDsl<T,C>,E>
protected List<NameValuePair> additionalHttpQueryParameters()
protected C withAdditionalHttpQueryParameters(List<NameValuePair> pairs)
public C withAdditionalHttpQueryParameters(NameValuePair pair)
withAdditionalHttpQueryParameters
in interface UpdateCommandDsl<T extends ResourceView<T,T>,C extends UpdateCommandDsl<T,C>>