public class BasicPersistentEntity<T,P extends PersistentProperty<P>> extends Object implements MutablePersistentEntity<T,P>
PersistentEntity
s.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 |
doWithAssociations(SimpleAssociationHandler handler) |
void |
doWithProperties(PropertyHandler<P> handler)
|
void |
doWithProperties(SimplePropertyHandler handler) |
<A extends Annotation> |
findAnnotation(Class<A> annotationType)
Looks up the annotation of the given type on the
PersistentEntity . |
protected EvaluationContext |
getEvaluationContext(Object rootObject)
Obtain a
EvaluationContext for a rootObject . |
protected EvaluationContext |
getEvaluationContext(Object rootObject,
ExpressionDependencies dependencies)
|
protected IsNewStrategy |
getFallbackIsNewStrategy()
Returns the default
IsNewStrategy to be used. |
IdentifierAccessor |
getIdentifierAccessor(Object bean)
Returns the
IdentifierAccessor for the given bean. |
P |
getIdProperty()
Returns the id property of the
PersistentEntity . |
InstanceCreatorMetadata<P> |
getInstanceCreatorMetadata()
Returns the
InstanceCreatorMetadata to be used to instantiate objects of this 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 . |
Iterable<P> |
getPersistentProperties(Class<? extends Annotation> annotationType)
Returns all properties equipped with an
Annotation of the given type. |
P |
getPersistentProperty(String name)
Obtains a
PersistentProperty instance by name. |
<B> PersistentPropertyAccessor<B> |
getPropertyAccessor(B bean)
Returns a
PersistentPropertyAccessor to access property values of the given bean. |
<B> PersistentPropertyPathAccessor<B> |
getPropertyPathAccessor(B bean)
Returns a
PersistentPropertyPathAccessor to access property values of the given bean. |
Class<T> |
getType()
Returns the resolved Java type of this entity.
|
Alias |
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. |
<A extends Annotation> |
isAnnotationPresent(Class<A> annotationType)
Checks whether the annotation of the given type is present on the
PersistentEntity . |
boolean |
isCreatorArgument(PersistentProperty<?> property)
Returns whether the given
PersistentProperty is referred to by a creator argument of the
PersistentEntity . |
boolean |
isIdProperty(PersistentProperty<?> property)
Returns whether the given
PersistentProperty is the id property of the entity. |
boolean |
isImmutable()
Returns whether the entity is considered immutable, i.e. clients shouldn't attempt to change instances via the
PersistentPropertyAccessor obtained via PersistentEntity.getPropertyAccessor(Object) . |
boolean |
isNew(Object bean)
Returns whether the given bean is considered new according to the static metadata.
|
boolean |
isVersionProperty(PersistentProperty<?> property)
Returns whether the given
PersistentProperty is the version property of the entity. |
Iterator<P> |
iterator() |
boolean |
requiresPropertyPopulation()
Returns whether the entity needs properties to be populated, i.e. if any property exists that's not initialized by
the constructor.
|
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 |
setEvaluationContextProvider(EvaluationContextProvider provider)
Sets the
EvaluationContextProvider to be used by the entity. |
void |
setPersistentPropertyAccessorFactory(PersistentPropertyAccessorFactory factory)
Sets the
PersistentPropertyAccessorFactory for the entity. |
void |
verify()
Callback method to trigger validation of the
PersistentEntity . |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
doWithAll, getPersistentProperty, getRequiredAnnotation, getRequiredIdProperty, getRequiredPersistentProperty, getRequiredVersionProperty, isConstructorArgument
forEach, spliterator
public BasicPersistentEntity(TypeInformation<T> information)
BasicPersistentEntity
from the given TypeInformation
.information
- must not be null.public BasicPersistentEntity(TypeInformation<T> information, @Nullable 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 null.comparator
- can be null.@Nullable 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 InstanceCreatorMetadata<P> getInstanceCreatorMetadata()
PersistentEntity
InstanceCreatorMetadata
to be used to instantiate objects of this PersistentEntity
.getInstanceCreatorMetadata
in interface PersistentEntity<T,P extends PersistentProperty<P>>
EntityInstantiator
or handled by custom conversion
mechanisms entirely.public boolean isCreatorArgument(PersistentProperty<?> property)
PersistentEntity
PersistentProperty
is referred to by a creator argument of the
PersistentEntity
.isCreatorArgument
in interface PersistentEntity<T,P extends PersistentProperty<P>>
property
- can be null.PersistentProperty
is referred to by a creator 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>>
property
- can be null.public boolean isVersionProperty(PersistentProperty<?> property)
PersistentEntity
PersistentProperty
is the version property of the entity.isVersionProperty
in interface PersistentEntity<T,P extends PersistentProperty<P>>
property
- can be null.public String getName()
PersistentEntity
getName
in interface PersistentEntity<T,P extends PersistentProperty<P>>
@Nullable 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
.@Nullable 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>>
public void setEvaluationContextProvider(EvaluationContextProvider provider)
MutablePersistentEntity
EvaluationContextProvider
to be used by the entity.setEvaluationContextProvider
in interface MutablePersistentEntity<T,P extends PersistentProperty<P>>
provider
- must not be null.@Nullable 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>>
@Nullable public P getPersistentProperty(String name)
PersistentEntity
PersistentProperty
instance by name.getPersistentProperty
in interface PersistentEntity<T,P extends PersistentProperty<P>>
name
- The name of the property. Can be null.PersistentProperty
or null if it doesn't exist.public Iterable<P> getPersistentProperties(Class<? extends Annotation> annotationType)
PersistentEntity
Annotation
of the given type.getPersistentProperties
in interface PersistentEntity<T,P extends PersistentProperty<P>>
annotationType
- must not be null.Iterator
if no match found. Never null.public Class<T> getType()
PersistentEntity
getType
in interface PersistentEntity<T,P extends PersistentProperty<P>>
public Alias 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 doWithProperties(SimplePropertyHandler handler)
doWithProperties
in interface PersistentEntity<T,P extends PersistentProperty<P>>
public void doWithAssociations(AssociationHandler<P> handler)
PersistentEntity
doWithAssociations
in interface PersistentEntity<T,P extends PersistentProperty<P>>
handler
- must not be null.public void doWithAssociations(SimpleAssociationHandler handler)
doWithAssociations
in interface PersistentEntity<T,P extends PersistentProperty<P>>
@Nullable public <A extends Annotation> A findAnnotation(Class<A> annotationType)
PersistentEntity
PersistentEntity
.findAnnotation
in interface PersistentEntity<T,P extends PersistentProperty<P>>
annotationType
- must not be null.public <A extends Annotation> boolean isAnnotationPresent(Class<A> annotationType)
PersistentEntity
PersistentEntity
.isAnnotationPresent
in interface PersistentEntity<T,P extends PersistentProperty<P>>
annotationType
- must not be null.Annotation
of given type is present.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>>
public void setPersistentPropertyAccessorFactory(PersistentPropertyAccessorFactory factory)
MutablePersistentEntity
PersistentPropertyAccessorFactory
for the entity. A PersistentPropertyAccessorFactory
creates PersistentPropertyAccessor
s for instances of this entity.setPersistentPropertyAccessorFactory
in interface MutablePersistentEntity<T,P extends PersistentProperty<P>>
factory
- must not be null.public <B> PersistentPropertyAccessor<B> getPropertyAccessor(B bean)
PersistentEntity
PersistentPropertyAccessor
to access property values of the given bean.getPropertyAccessor
in interface PersistentEntity<T,P extends PersistentProperty<P>>
bean
- must not be null.PersistentPropertyAccessor
.public <B> PersistentPropertyPathAccessor<B> getPropertyPathAccessor(B bean)
PersistentEntity
PersistentPropertyPathAccessor
to access property values of the given bean.getPropertyPathAccessor
in interface PersistentEntity<T,P extends PersistentProperty<P>>
bean
- must not be null.PersistentPropertyPathAccessor
public IdentifierAccessor getIdentifierAccessor(Object bean)
PersistentEntity
IdentifierAccessor
for the given bean.getIdentifierAccessor
in interface PersistentEntity<T,P extends PersistentProperty<P>>
bean
- must not be null.IdentifierAccessor
.public boolean isNew(Object bean)
PersistentEntity
isNew
in interface PersistentEntity<T,P extends PersistentProperty<P>>
bean
- must not be null.public boolean isImmutable()
PersistentEntity
PersistentPropertyAccessor
obtained via PersistentEntity.getPropertyAccessor(Object)
.isImmutable
in interface PersistentEntity<T,P extends PersistentProperty<P>>
Immutable
public boolean requiresPropertyPopulation()
PersistentEntity
requiresPropertyPopulation
in interface PersistentEntity<T,P extends PersistentProperty<P>>
public Iterator<P> iterator()
iterator
in interface Iterable<P extends PersistentProperty<P>>
protected EvaluationContext getEvaluationContext(Object rootObject)
EvaluationContext
for a rootObject
.rootObject
- must not be null.protected EvaluationContext getEvaluationContext(Object rootObject, ExpressionDependencies dependencies)
rootObject
- must not be null.dependencies
- must not be null.ExpressionDependencies
.protected IsNewStrategy getFallbackIsNewStrategy()
IsNewStrategy
to be used. Will be a PersistentEntityIsNewStrategy
by default.
Note, that this strategy only gets used if the entity doesn't implement Persistable
as this indicates the
user wants to be in control over whether an entity is new or not.Copyright © 2011–2023 Pivotal Software, Inc.. All rights reserved.