public class BasicPersistentEntity<T,P extends PersistentProperty<P>> extends Object implements MutablePersistentEntity<T,P>
PersistentEntity
s.Type | Property and Description |
---|---|
boolean |
hasId
Returns whether the
PersistentEntity has an id property. |
boolean |
hasVersion
Returns whether the
PersistentEntity has a version property. |
Constructor and Description |
---|
BasicPersistentEntity(TypeInformation<T> information)
Creates a new
BasicPersistentEntity from the given TypeInformation . |
BasicPersistentEntity(TypeInformation<T> information,
Comparator<P> comparator)
|
Modifier and Type | Method and Description |
---|---|
void |
addAssociation(Association<P> association)
Adds an
Association to the entity. |
void |
addPersistentProperty(P property)
Adds a
PersistentProperty to the entity. |
void |
doWithAssociations(AssociationHandler<P> handler)
|
void |
doWithProperties(PropertyHandler<P> handler)
|
P |
getIdProperty()
Returns the id property of the
PersistentEntity . |
String |
getName()
The entity name including any package prefix.
|
PreferredConstructor<T,P> |
getPersistenceConstructor()
Returns the
PreferredConstructor to be used to instantiate objects of this PersistentEntity . |
P |
getPersistentProperty(String name)
Obtains a
PersistentProperty instance by name. |
Class<T> |
getType()
Returns the resolved Java type of this entity.
|
Object |
getTypeAlias()
Returns the alias to be used when storing type information.
|
TypeInformation<T> |
getTypeInformation()
Returns the
TypeInformation backing this PersistentEntity . |
P |
getVersionProperty()
Returns the version property of the
PersistentEntity . |
boolean |
hasIdProperty()
Returns whether the
PersistentEntity has an id property. |
boolean |
hasVersionProperty()
Returns whether the
PersistentEntity has a version property. |
boolean |
isConstructorArgument(PersistentProperty<?> property)
Returns whether the given
PersistentProperty is referred to by a constructor argument of the
PersistentEntity . |
boolean |
isIdProperty(PersistentProperty<?> property)
Returns whether the given
PersistentProperty is the id property of the entity. |
boolean |
isVersionProperty(PersistentProperty<?> property)
Returns whether the given
PersistentProperty is the version property of the entity. |
protected P |
returnPropertyIfBetterIdPropertyCandidateOrNull(P property)
Returns the given property if it is a better candidate for the id property than the current id property.
|
void |
verify()
Callback method to trigger validation of the
PersistentEntity . |
hasIdProperty
in interface PersistentEntity<T,P extends PersistentProperty<P>>
hasVersionProperty
in interface PersistentEntity<T,P extends PersistentProperty<P>>
public BasicPersistentEntity(TypeInformation<T> information)
BasicPersistentEntity
from the given TypeInformation
.information
- must not be null.public BasicPersistentEntity(TypeInformation<T> information, Comparator<P> comparator)
BasicPersistentEntity
for the given TypeInformation
and Comparator
. The given
Comparator
will be used to define the order of the PersistentProperty
instances added to the
entity.information
- must not be nullcomparator
- public PreferredConstructor<T,P> getPersistenceConstructor()
PersistentEntity
PreferredConstructor
to be used to instantiate objects of this PersistentEntity
.getPersistenceConstructor
in interface PersistentEntity<T,P extends PersistentProperty<P>>
EntityInstantiator
or handled by custom conversion mechanisms entirely.public boolean isConstructorArgument(PersistentProperty<?> property)
PersistentEntity
PersistentProperty
is referred to by a constructor argument of the
PersistentEntity
.isConstructorArgument
in interface PersistentEntity<T,P extends PersistentProperty<P>>
PersistentProperty
is referred to by a constructor argument or false
if not or null.public boolean isIdProperty(PersistentProperty<?> property)
PersistentEntity
PersistentProperty
is the id property of the entity.isIdProperty
in interface PersistentEntity<T,P extends PersistentProperty<P>>
public boolean isVersionProperty(PersistentProperty<?> property)
PersistentEntity
PersistentProperty
is the version property of the entity.isVersionProperty
in interface PersistentEntity<T,P extends PersistentProperty<P>>
public String getName()
PersistentEntity
getName
in interface PersistentEntity<T,P extends PersistentProperty<P>>
public P getIdProperty()
PersistentEntity
PersistentEntity
. Can be null in case this is an entity
completely handled by a custom conversion.getIdProperty
in interface PersistentEntity<T,P extends PersistentProperty<P>>
PersistentEntity
.public P getVersionProperty()
PersistentEntity
PersistentEntity
. Can be null in case no version property is
available on the entity.getVersionProperty
in interface PersistentEntity<T,P extends PersistentProperty<P>>
PersistentEntity
.public boolean hasIdProperty()
PersistentEntity
PersistentEntity
has an id property. If this call returns true,
PersistentEntity.getIdProperty()
will return a non-null value.hasIdProperty
in interface PersistentEntity<T,P extends PersistentProperty<P>>
public boolean hasVersionProperty()
PersistentEntity
PersistentEntity
has a version property. If this call returns true,
PersistentEntity.getVersionProperty()
will return a non-null value.hasVersionProperty
in interface PersistentEntity<T,P extends PersistentProperty<P>>
public void addPersistentProperty(P property)
MutablePersistentEntity
PersistentProperty
to the entity.addPersistentProperty
in interface MutablePersistentEntity<T,P extends PersistentProperty<P>>
protected P returnPropertyIfBetterIdPropertyCandidateOrNull(P property)
property
- the new id property candidate, will never be null.public void addAssociation(Association<P> association)
MutablePersistentEntity
Association
to the entity.addAssociation
in interface MutablePersistentEntity<T,P extends PersistentProperty<P>>
public P getPersistentProperty(String name)
PersistentEntity
PersistentProperty
instance by name.getPersistentProperty
in interface PersistentEntity<T,P extends PersistentProperty<P>>
name
- The name of the propertyPersistentProperty
or null if it doesn't exist.public Class<T> getType()
PersistentEntity
getType
in interface PersistentEntity<T,P extends PersistentProperty<P>>
public Object getTypeAlias()
PersistentEntity
getTypeAlias
in interface PersistentEntity<T,P extends PersistentProperty<P>>
public TypeInformation<T> getTypeInformation()
PersistentEntity
TypeInformation
backing this PersistentEntity
.getTypeInformation
in interface PersistentEntity<T,P extends PersistentProperty<P>>
public void doWithProperties(PropertyHandler<P> handler)
PersistentEntity
doWithProperties
in interface PersistentEntity<T,P extends PersistentProperty<P>>
handler
- must not be null.public void doWithAssociations(AssociationHandler<P> handler)
PersistentEntity
doWithAssociations
in interface PersistentEntity<T,P extends PersistentProperty<P>>
handler
- must not be null.public void verify()
MutablePersistentEntity
PersistentEntity
. As MutablePersistentEntity
is not
immutable there might be some verification steps necessary after the object has reached is final state.verify
in interface MutablePersistentEntity<T,P extends PersistentProperty<P>>
Copyright © 2011-2013-2013 Pivotal. All Rights Reserved.