org.javers.core.metamodel.type.ValueObjectType 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.type;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
/**
* ValueObject class in client's domain model.
*
*
* Has list of mutable properties but no unique identifier.
*
*
* Two ValueObjects are compared property by property.
*
*
* Example:
*
* class Address {
* private String city;
* private String street;
* private String zip;
* ...
* }
*
*
* @author bartosz walacik
*/
public class ValueObjectType extends ManagedType{
private final boolean defaultType;
ValueObjectType(ManagedClass valueObject){
super(valueObject);
this.defaultType = false;
}
public ValueObjectType(Class baseJavaClass, List allProperties){
this(new ManagedClass(baseJavaClass, allProperties, Collections.emptyList()));
}
ValueObjectType(ManagedClass valueObject, Optional typeName, boolean isDefault) {
super(valueObject, typeName);
this.defaultType = isDefault;
}
@Override
ValueObjectType spawn(ManagedClass managedClass, Optional typeName) {
return new ValueObjectType(managedClass, typeName, defaultType);
}
@Override
public boolean canBePrototype() {
return !defaultType;
}
}