com.commercetools.history.models.change_history.Record Maven / Gradle / Ivy
Show all versions of commercetools-sdk-java-history Show documentation
package com.commercetools.history.models.change_history;
import java.time.*;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
import javax.annotation.Nullable;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import com.commercetools.history.models.change.Change;
import com.commercetools.history.models.common.KeyReference;
import com.commercetools.history.models.common.ResourceIdentifier;
import com.commercetools.history.models.label.Label;
import com.fasterxml.jackson.annotation.*;
import com.fasterxml.jackson.databind.annotation.*;
import io.vrap.rmf.base.client.utils.Generated;
/**
* Captures the differences between the previous and next version of a resource.
* The maximum number of Records that can be stored and their retention period are subject to a limit.
*
*
* Example to create an instance using the builder pattern
*
*
* Record record = Record.builder()
* .version(1)
* .previousVersion(1)
* .type("{type}")
* .modifiedBy(modifiedByBuilder -> modifiedByBuilder)
* .modifiedAt("{modifiedAt}")
* .label(labelBuilder -> labelBuilder)
* .previousLabel(previousLabelBuilder -> previousLabelBuilder)
* .plusChanges(changesBuilder -> changesBuilder)
* .resource(resourceBuilder -> resourceBuilder)
* .plusStores(storesBuilder -> storesBuilder)
* .withoutChanges(true)
* .build()
*
*
*/
@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen")
@JsonDeserialize(as = RecordImpl.class)
public interface Record {
/**
* Version of the resource after the change.
* For more information on how the version is incremented, see Optimistic Concurrency Control.
* @return version
*/
@NotNull
@JsonProperty("version")
public Integer getVersion();
/**
* Version of the resource before the change.
* @return previousVersion
*/
@NotNull
@JsonProperty("previousVersion")
public Integer getPreviousVersion();
/**
* Indicates the type of change. For creation, update, or deletion, the value is "ResourceCreated"
, "ResourceUpdated"
, or "ResourceDeleted"
respectively.
* @return type
*/
@NotNull
@JsonProperty("type")
public String getType();
/**
* Information about the user or API Client who performed the change.
* @return modifiedBy
*/
@NotNull
@Valid
@JsonProperty("modifiedBy")
public ModifiedBy getModifiedBy();
/**
* Date and time (UTC) when the change was made.
* @return modifiedAt
*/
@NotNull
@JsonProperty("modifiedAt")
public String getModifiedAt();
/**
* Information that describes the resource after the change.
* @return label
*/
@NotNull
@Valid
@JsonProperty("label")
public Label getLabel();
/**
* Information that describes the resource before the change.
* @return previousLabel
*/
@NotNull
@Valid
@JsonProperty("previousLabel")
public Label getPreviousLabel();
/**
* Shows the differences in the resource between previousVersion
and version
.
* The value is not identical to the actual array of update actions sent and is not limited to update actions (see, for example, Optimistic Concurrency Control).
* @return changes
*/
@NotNull
@Valid
@JsonProperty("changes")
public List getChanges();
/**
* ResourceIdentifier of the changed resource.
* @return resource
*/
@NotNull
@Valid
@JsonProperty("resource")
public ResourceIdentifier getResource();
/**
* References to the Stores associated with the Change.
* @return stores
*/
@NotNull
@Valid
@JsonProperty("stores")
public List getStores();
/**
* Reference to the Business Unit associated with the Change.
* @return businessUnit
*/
@Valid
@JsonProperty("businessUnit")
public KeyReference getBusinessUnit();
/**
* true
if no change was detected.
* The version number of the resource can be increased even without any change in the resource.
* @return withoutChanges
*/
@NotNull
@JsonProperty("withoutChanges")
public Boolean getWithoutChanges();
/**
* Version of the resource after the change.
* For more information on how the version is incremented, see Optimistic Concurrency Control.
* @param version value to be set
*/
public void setVersion(final Integer version);
/**
* Version of the resource before the change.
* @param previousVersion value to be set
*/
public void setPreviousVersion(final Integer previousVersion);
/**
* Indicates the type of change. For creation, update, or deletion, the value is "ResourceCreated"
, "ResourceUpdated"
, or "ResourceDeleted"
respectively.
* @param type value to be set
*/
public void setType(final String type);
/**
* Information about the user or API Client who performed the change.
* @param modifiedBy value to be set
*/
public void setModifiedBy(final ModifiedBy modifiedBy);
/**
* Date and time (UTC) when the change was made.
* @param modifiedAt value to be set
*/
public void setModifiedAt(final String modifiedAt);
/**
* Information that describes the resource after the change.
* @param label value to be set
*/
public void setLabel(final Label label);
/**
* Information that describes the resource before the change.
* @param previousLabel value to be set
*/
public void setPreviousLabel(final Label previousLabel);
/**
* Shows the differences in the resource between previousVersion
and version
.
* The value is not identical to the actual array of update actions sent and is not limited to update actions (see, for example, Optimistic Concurrency Control).
* @param changes values to be set
*/
@JsonIgnore
public void setChanges(final Change... changes);
/**
* Shows the differences in the resource between previousVersion
and version
.
* The value is not identical to the actual array of update actions sent and is not limited to update actions (see, for example, Optimistic Concurrency Control).
* @param changes values to be set
*/
public void setChanges(final List changes);
/**
* ResourceIdentifier of the changed resource.
* @param resource value to be set
*/
public void setResource(final ResourceIdentifier resource);
/**
* References to the Stores associated with the Change.
* @param stores values to be set
*/
@JsonIgnore
public void setStores(final KeyReference... stores);
/**
* References to the Stores associated with the Change.
* @param stores values to be set
*/
public void setStores(final List stores);
/**
* Reference to the Business Unit associated with the Change.
* @param businessUnit value to be set
*/
public void setBusinessUnit(final KeyReference businessUnit);
/**
* true
if no change was detected.
* The version number of the resource can be increased even without any change in the resource.
* @param withoutChanges value to be set
*/
public void setWithoutChanges(final Boolean withoutChanges);
/**
* factory method
* @return instance of Record
*/
public static Record of() {
return new RecordImpl();
}
/**
* factory method to create a shallow copy Record
* @param template instance to be copied
* @return copy instance
*/
public static Record of(final Record template) {
RecordImpl instance = new RecordImpl();
instance.setVersion(template.getVersion());
instance.setPreviousVersion(template.getPreviousVersion());
instance.setType(template.getType());
instance.setModifiedBy(template.getModifiedBy());
instance.setModifiedAt(template.getModifiedAt());
instance.setLabel(template.getLabel());
instance.setPreviousLabel(template.getPreviousLabel());
instance.setChanges(template.getChanges());
instance.setResource(template.getResource());
instance.setStores(template.getStores());
instance.setBusinessUnit(template.getBusinessUnit());
instance.setWithoutChanges(template.getWithoutChanges());
return instance;
}
/**
* factory method to create a deep copy of Record
* @param template instance to be copied
* @return copy instance
*/
@Nullable
public static Record deepCopy(@Nullable final Record template) {
if (template == null) {
return null;
}
RecordImpl instance = new RecordImpl();
instance.setVersion(template.getVersion());
instance.setPreviousVersion(template.getPreviousVersion());
instance.setType(template.getType());
instance.setModifiedBy(
com.commercetools.history.models.change_history.ModifiedBy.deepCopy(template.getModifiedBy()));
instance.setModifiedAt(template.getModifiedAt());
instance.setLabel(com.commercetools.history.models.label.Label.deepCopy(template.getLabel()));
instance.setPreviousLabel(com.commercetools.history.models.label.Label.deepCopy(template.getPreviousLabel()));
instance.setChanges(Optional.ofNullable(template.getChanges())
.map(t -> t.stream()
.map(com.commercetools.history.models.change.Change::deepCopy)
.collect(Collectors.toList()))
.orElse(null));
instance.setResource(
com.commercetools.history.models.common.ResourceIdentifier.deepCopy(template.getResource()));
instance.setStores(Optional.ofNullable(template.getStores())
.map(t -> t.stream()
.map(com.commercetools.history.models.common.KeyReference::deepCopy)
.collect(Collectors.toList()))
.orElse(null));
instance.setBusinessUnit(
com.commercetools.history.models.common.KeyReference.deepCopy(template.getBusinessUnit()));
instance.setWithoutChanges(template.getWithoutChanges());
return instance;
}
/**
* builder factory method for Record
* @return builder
*/
public static RecordBuilder builder() {
return RecordBuilder.of();
}
/**
* create builder for Record instance
* @param template instance with prefilled values for the builder
* @return builder
*/
public static RecordBuilder builder(final Record template) {
return RecordBuilder.of(template);
}
/**
* accessor map function
* @param mapped type
* @param helper function to map the object
* @return mapped value
*/
default T withRecord(Function helper) {
return helper.apply(this);
}
/**
* gives a TypeReference for usage with Jackson DataBind
* @return TypeReference
*/
public static com.fasterxml.jackson.core.type.TypeReference typeReference() {
return new com.fasterxml.jackson.core.type.TypeReference() {
@Override
public String toString() {
return "TypeReference";
}
};
}
}