public interface PersistentEntity<T,P extends PersistentProperty<P>> extends Iterable<P>
Iterator
is not guaranteed.Modifier and Type | Method and Description |
---|---|
default void |
doWithAll(PropertyHandler<P> handler)
Applies the given
PropertyHandler to both all PersistentProperty s as well as all inverse
properties of all Association s. |
void |
doWithAssociations(AssociationHandler<P> handler)
|
void |
doWithAssociations(SimpleAssociationHandler handler)
|
void |
doWithProperties(PropertyHandler<P> handler)
|
void |
doWithProperties(SimplePropertyHandler handler)
Applies the given
SimplePropertyHandler to all PersistentProperty s contained in this
PersistentEntity . |
<A extends Annotation> |
findAnnotation(Class<A> annotationType)
Looks up the annotation of the given type on the
PersistentEntity . |
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()
Deprecated.
since 2.7, use
getInstanceCreatorMetadata() . |
Iterable<P> |
getPersistentProperties(Class<? extends Annotation> annotationType)
Returns all properties equipped with an
Annotation of the given type. |
default P |
getPersistentProperty(Class<? extends Annotation> annotationType)
Returns the first property 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. |
default <A extends Annotation> |
getRequiredAnnotation(Class<A> annotationType)
Returns the required annotation of the given type on the
PersistentEntity . |
default P |
getRequiredIdProperty()
Returns the id property of the
PersistentEntity . |
default P |
getRequiredPersistentProperty(String name)
Returns the
PersistentProperty with the given name. |
default P |
getRequiredVersionProperty()
Returns the version property of the
PersistentEntity . |
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 . |
default boolean |
isConstructorArgument(PersistentProperty<?> property)
Deprecated.
since 3.0, use
isCreatorArgument(PersistentProperty) instead. |
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 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. |
boolean |
requiresPropertyPopulation()
Returns whether the entity needs properties to be populated, i.e. if any property exists that's not initialized
by the constructor.
|
forEach, iterator, spliterator
String getName()
@Nullable @Deprecated PreferredConstructor<T,P> getPersistenceConstructor()
getInstanceCreatorMetadata()
.PreferredConstructor
to be used to instantiate objects of this PersistentEntity
.EntityInstantiator
or handled by custom conversion
mechanisms entirely.@Nullable InstanceCreatorMetadata<P> getInstanceCreatorMetadata()
InstanceCreatorMetadata
to be used to instantiate objects of this PersistentEntity
.EntityInstantiator
or handled by custom conversion
mechanisms entirely.@Deprecated default boolean isConstructorArgument(PersistentProperty<?> property)
isCreatorArgument(PersistentProperty)
instead.PersistentProperty
is referred to by a constructor argument of the
PersistentEntity
.property
- can be null.PersistentProperty
is referred to by a constructor argument or false
if not or null.boolean isCreatorArgument(PersistentProperty<?> property)
PersistentProperty
is referred to by a creator argument of the
PersistentEntity
.property
- can be null.PersistentProperty
is referred to by a creator argument or false if
not or null.boolean isIdProperty(PersistentProperty<?> property)
PersistentProperty
is the id property of the entity.property
- can be null.boolean isVersionProperty(PersistentProperty<?> property)
PersistentProperty
is the version property of the entity.property
- can be null.@Nullable P getIdProperty()
PersistentEntity
. Can be null in case this is an entity
completely handled by a custom conversion.PersistentEntity
.default P getRequiredIdProperty()
PersistentEntity
.PersistentEntity
.IllegalStateException
- if PersistentEntity
does not define an id property.@Nullable P getVersionProperty()
PersistentEntity
. Can be null in case no version property
is available on the entity.PersistentEntity
.default P getRequiredVersionProperty()
PersistentEntity
. Can be null in case no version property
is available on the entity.PersistentEntity
.IllegalStateException
- if PersistentEntity
does not define a version property.@Nullable P getPersistentProperty(String name)
PersistentProperty
instance by name.name
- The name of the property. Can be null.PersistentProperty
or null if it doesn't exist.default P getRequiredPersistentProperty(String name)
PersistentProperty
with the given name.name
- the name of the property. Can be null or empty.PersistentProperty
with the given name.IllegalStateException
- in case no property with the given name exists.@Nullable default P getPersistentProperty(Class<? extends Annotation> annotationType)
Annotation
of the given type.annotationType
- must not be null.Iterable<P> getPersistentProperties(Class<? extends Annotation> annotationType)
Annotation
of the given type.annotationType
- must not be null.Iterator
if no match found. Never null.boolean hasIdProperty()
PersistentEntity
has an id property. If this call returns true,
getIdProperty()
will return a non-null value.boolean hasVersionProperty()
PersistentEntity
has a version property. If this call returns true,
getVersionProperty()
will return a non-null value.Class<T> getType()
Alias getTypeAlias()
TypeInformation<T> getTypeInformation()
TypeInformation
backing this PersistentEntity
.void doWithProperties(PropertyHandler<P> handler)
PropertyHandler
to all PersistentProperty
s contained in this
PersistentEntity
. The iteration order is undefined.handler
- must not be null.void doWithProperties(SimplePropertyHandler handler)
SimplePropertyHandler
to all PersistentProperty
s contained in this
PersistentEntity
. The iteration order is undefined.handler
- must not be null.void doWithAssociations(AssociationHandler<P> handler)
AssociationHandler
to all Association
contained in this
PersistentEntity
. The iteration order is undefined.handler
- must not be null.void doWithAssociations(SimpleAssociationHandler handler)
SimpleAssociationHandler
to all Association
contained in this
PersistentEntity
. The iteration order is undefined.handler
- must not be null.default void doWithAll(PropertyHandler<P> handler)
PropertyHandler
to both all PersistentProperty
s as well as all inverse
properties of all Association
s. The iteration order is undefined.handler
- must not be null.@Nullable <A extends Annotation> A findAnnotation(Class<A> annotationType)
PersistentEntity
.annotationType
- must not be null.default <A extends Annotation> A getRequiredAnnotation(Class<A> annotationType) throws IllegalStateException
PersistentEntity
.annotationType
- must not be null.IllegalStateException
- if the required annotationType
is not found.<A extends Annotation> boolean isAnnotationPresent(Class<A> annotationType)
PersistentEntity
.annotationType
- must not be null.Annotation
of given type is present.<B> PersistentPropertyAccessor<B> getPropertyAccessor(B bean)
PersistentPropertyAccessor
to access property values of the given bean.bean
- must not be null.PersistentPropertyAccessor
.<B> PersistentPropertyPathAccessor<B> getPropertyPathAccessor(B bean)
PersistentPropertyPathAccessor
to access property values of the given bean.bean
- must not be null.PersistentPropertyPathAccessor
IdentifierAccessor getIdentifierAccessor(Object bean)
IdentifierAccessor
for the given bean.bean
- must not be null.IdentifierAccessor
.boolean isNew(Object bean)
bean
- must not be null.IllegalArgumentException
- in case the given bean is not an instance of the typ represented by the
PersistentEntity
.boolean isImmutable()
PersistentPropertyAccessor
obtained via getPropertyAccessor(Object)
.Immutable
boolean requiresPropertyPopulation()
Copyright © 2011–2023 Pivotal Software, Inc.. All rights reserved.