org.javers.core.metamodel.object.InstanceId Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of javers-core Show documentation
Show all versions of javers-core Show documentation
JaVers - object auditing and diff framework for Java
package org.javers.core.metamodel.object;
import static org.javers.common.validation.Validate.argumentsAreNotNull;
/**
* Entity instance global identifier, consists of Entity reference and cdoId
*
* @author bartosz walacik
*/
public class InstanceId extends GlobalId {
private final Object cdoId;
private final String cdoIdAsString;
InstanceId(String typeName, Object cdoId) {
super(typeName);
argumentsAreNotNull(cdoId);
this.cdoId = cdoId;
this.cdoIdAsString = cdoId.toString();
}
public InstanceId(String typeName, Object cdoId, String cdoIdAsString) {
super(typeName);
argumentsAreNotNull(cdoId, cdoIdAsString);
this.cdoId = cdoId;
this.cdoIdAsString = cdoIdAsString;
}
/**
* Identifier of (client's) Entity instance, should be unique in Entity scope.
* For example database primary key or any domain identifier like user.login
*/
public Object getCdoId() {
return cdoId;
}
public String value() {
return getTypeName()+"/"+cdoIdAsString;
}
@Override
public String toString() {
return getTypeNameShort()+"/"+cdoIdAsString;
}
}