Package org.pipservices3.commons.data
Interface IVersioned
public interface IVersioned
Interface for data objects that can be versioned.
Versioning is often used as optimistic concurrency mechanism.
The version doesn't have to be a number, but it is recommended to use sequential values to determine if one object has newer or older version than another one.
It is a common pattern to use the time of change as the object version.
### Example ###
public class MyData implements IStringIdentifiable, IVersioned {
private String id;
public String field1;
public int field2;
private String version;
...
}
public void updateData(String correlationId, MyData item) {
...
if (item.getVersion() < oldItem.getVersion()) {
throw new ConcurrencyException(null, "VERSION_CONFLICT", "The change has older version stored value");
}
...
}
-
Method Summary
Modifier and TypeMethodDescriptionGets the object versionvoid
setVersion
(String value) Sets the object version
-
Method Details
-
getVersion
String getVersion()Gets the object version- Returns:
- the object version
-
setVersion
Sets the object version- Parameters:
value
- a new object version
-