org.javers.core.metamodel.clazz.EntityDefinition 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.clazz;
import org.javers.core.metamodel.type.EntityType;
import java.util.List;
import static org.javers.common.collections.Lists.immutableCopyOf;
/**
* Recipe for {@link EntityType}
*
* @see EntityDefinitionBuilder
* @author bartosz walacik
*/
public class EntityDefinition extends ClientsClassDefinition {
private final List idPropertyNames;
private final boolean shallowReference;
/**
* Recipe for Entity with Id-property selected by @Id annotation
*/
public EntityDefinition(Class entity) {
this(new EntityDefinitionBuilder(entity));
}
/**
* Recipe for Entity with Id-property selected explicitly by name
*/
public EntityDefinition(Class entity, String idPropertyName){
this(new EntityDefinitionBuilder(entity)
.withIdPropertyName(idPropertyName));
}
public EntityDefinition(Class entity, String idPropertyName, List ignoredProperties) {
this(new EntityDefinitionBuilder(entity)
.withIdPropertyName(idPropertyName)
.withIgnoredProperties(ignoredProperties));
}
EntityDefinition(EntityDefinitionBuilder builder) {
super(builder);
this.idPropertyNames = immutableCopyOf(builder.getIdPropertyNames());
this.shallowReference = builder.isShallowReference();
}
public boolean hasExplicitId() {
return idPropertyNames.size() > 0;
}
/**
* @return an immutable, non-null list
*/
public List getIdPropertyNames() {
return idPropertyNames;
}
public boolean isShallowReference() {
return shallowReference;
}
}