Interface PersistentProperty<P extends PersistentProperty<P>>

All Known Implementing Classes:
AbstractPersistentProperty, AnnotationBasedPersistentProperty

public interface PersistentProperty<P extends PersistentProperty<P>>
Author:
Graeme Rocher, Jon Brisbin, Oliver Gierke, Mark Paluch, Jens Schauder, Christoph Strobl, Johannes Englmeier
  • Method Details

    • getOwner

      PersistentEntity<?,P> getOwner()
      Returns the PersistentEntity owning the current PersistentProperty.
      Returns:
      never null.
    • getName

      String getName()
      The name of the property
      Returns:
      The property name
    • getType

      Class<?> getType()
      The type of the property
      Returns:
      The property type
    • getTypeInformation

      TypeInformation<?> getTypeInformation()
      Returns the TypeInformation of the property.
      Returns:
    • getPersistentEntityTypeInformation

      Iterable<? extends TypeInformation<?>> getPersistentEntityTypeInformation()
      Returns the detected TypeInformations if the property references a PersistentEntity. Will return an empty Iterable in case it refers to a simple type. Will return the Collection's component types or the Map's value type transparently.
      Returns:
      never null.
      Since:
      2.6
    • getGetter

      @Nullable Method getGetter()
      Returns the getter method to access the property value if available. Might return null in case there is no getter method with a return type assignable to the actual property's type.
      Returns:
      the getter method to access the property value if available, otherwise null.
    • getRequiredGetter

      default Method getRequiredGetter()
    • getSetter

      @Nullable Method getSetter()
      Returns the setter method to set a property value. Might return null in case there is no setter available.
      Returns:
      the setter method to set a property value if available, otherwise null.
    • getRequiredSetter

      default Method getRequiredSetter()
    • getWither

      @Nullable Method getWither()
      Returns the with Method to set a property value on a new object instance. Might return null in case there is no with available.

      With methods are property-bound instance methods that accept a single argument of the property type creating a new object instance.

       class Person {
              final String id;
              final String name;
      
              // …
      
              Person withName(String name) {
                      return new Person(this.id, name);
              }
       }
       
      Returns:
      the with Method to set a property value on a new object instance if available, otherwise null.
      Since:
      2.1
    • getRequiredWither

      default Method getRequiredWither()
    • getField

      @Nullable Field getField()
    • getRequiredField

      default Field getRequiredField()
    • getSpelExpression

      @Nullable String getSpelExpression()
      Returns:
      null if no expression defined.
    • getAssociation

      @Nullable Association<P> getAssociation()
      Returns:
      null if property is not part of an Association.
    • getRequiredAssociation

      default Association<P> getRequiredAssociation()
      Get the Association of this property.
      Returns:
      never null.
      Throws:
      IllegalStateException - if not involved in an Association.
    • isEntity

      boolean isEntity()
      Returns whether the type of the PersistentProperty is actually to be regarded as PersistentEntity in turn.
      Returns:
      true a PersistentEntity.
    • isIdProperty

      boolean isIdProperty()
      Returns whether the property is a potential identifier property of the owning PersistentEntity. This method is mainly used by PersistentEntity implementation to discover id property candidates on PersistentEntity creation you should rather call PersistentEntity.isIdProperty(PersistentProperty) to determine whether the current property is the id property of that PersistentEntity under consideration.
      Returns:
      true if the id property.
    • isVersionProperty

      boolean isVersionProperty()
      Returns whether the current property is a potential version property of the owning PersistentEntity. This method is mainly used by PersistentEntity implementation to discover version property candidates on PersistentEntity creation you should rather call PersistentEntity.isVersionProperty(PersistentProperty) to determine whether the current property is the version property of that PersistentEntity under consideration.
      Returns:
    • isCollectionLike

      boolean isCollectionLike()
      Returns whether the property is a Collection, Iterable or an array.
      Returns:
    • isMap

      boolean isMap()
      Returns whether the property is a Map.
      Returns:
    • isArray

      boolean isArray()
      Returns whether the property is an array.
      Returns:
    • isTransient

      boolean isTransient()
      Returns whether the property is transient.
      Returns:
    • isWritable

      boolean isWritable()
      Returns whether the current property is writable, i.e. if the value held for it shall be written to the data store.
      Returns:
      Since:
      1.9
    • isImmutable

      boolean isImmutable()
      Returns whether the current property is immutable, i.e. if there is no setter or the backing Field is final.
      Returns:
      Since:
      2.1
      See Also:
    • isAssociation

      boolean isAssociation()
      Returns whether the property is an Association.
      Returns:
    • getComponentType

      @Nullable Class<?> getComponentType()
      Returns the component type of the type if it is a Collection. Will return the type of the key if the property is a Map.
      Returns:
      the component type, the map's key type or null if neither Collection nor Map.
    • getRawType

      Class<?> getRawType()
      Returns the raw type as it's pulled from from the reflected property.
      Returns:
      the raw type of the property.
    • getMapValueType

      @Nullable Class<?> getMapValueType()
      Returns the type of the values if the property is a Map.
      Returns:
      the map's value type or null if no Map
    • getActualType

      Class<?> getActualType()
      Returns the actual type of the property. This will be the original property type if no generics were used, the component type for collection-like types and arrays as well as the value type for map properties.
      Returns:
    • findAnnotation

      @Nullable <A extends Annotation> A findAnnotation(Class<A> annotationType)
      Looks up the annotation of the given type on the PersistentProperty. Will inspect accessors and the potentially backing field and traverse accessor methods to potentially available super types.
      Parameters:
      annotationType - the annotation to look up, must not be null.
      Returns:
      the annotation of the given type. Can be null.
      See Also:
      • AnnotationUtils.findAnnotation(Method, Class)
    • getRequiredAnnotation

      default <A extends Annotation> A getRequiredAnnotation(Class<A> annotationType) throws IllegalStateException
      Looks up the annotation of the given type on the PersistentProperty. Will inspect accessors and the potentially backing field and traverse accessor methods to potentially available super types.
      Parameters:
      annotationType - the annotation to look up, must not be null.
      Returns:
      the annotation of the given type.
      Throws:
      IllegalStateException - if the required annotationType is not found.
      Since:
      2.0
    • findPropertyOrOwnerAnnotation

      @Nullable <A extends Annotation> A findPropertyOrOwnerAnnotation(Class<A> annotationType)
      Looks up the annotation of the given type on the property and the owning type if no annotation can be found on it. Useful to lookup annotations that can be configured on the type but overridden on an individual property.
      Parameters:
      annotationType - must not be null.
      Returns:
      the annotation of the given type. Can be null.
    • isAnnotationPresent

      boolean isAnnotationPresent(Class<? extends Annotation> annotationType)
      Returns whether the PersistentProperty has an annotation of the given type.
      Parameters:
      annotationType - the annotation to lookup, must not be null.
      Returns:
      whether the PersistentProperty has an annotation of the given type.
    • usePropertyAccess

      boolean usePropertyAccess()
      Returns whether property access shall be used for reading the property value. This means it will use the getter instead of field access.
      Returns:
    • hasActualTypeAnnotation

      default boolean hasActualTypeAnnotation(Class<? extends Annotation> annotationType)
      Returns whether the actual type of the property carries the given annotation.
      Parameters:
      annotationType - must not be null.
      Returns:
      Since:
      2.1
      See Also:
    • getAssociationTargetType

      @Nullable Class<?> getAssociationTargetType()
      Return the type the property refers to in case it's an association, i.e. isAssociation() returns true. That means, that implementations must return a non-null value from this method in that case. We also recommend to return null for non-associations right away to establish symmetry between this method and isAssociation().
      Returns:
      the type the property refers to in case it's an association, i.e. isAssociation() returns true.
      Since:
      2.1
    • getAssociationTargetTypeInformation

      @Nullable TypeInformation<?> getAssociationTargetTypeInformation()
      Return the type the property refers to in case it's an association, i.e. isAssociation() returns true. That means, that implementations must return a non-null value from this method in that case. We also recommend to return null for non-associations right away to establish symmetry between this method and isAssociation().
      Returns:
      the type the property refers to in case it's an association, i.e. isAssociation() returns true.
      Since:
      2.6
    • getAccessorForOwner

      default <T> PersistentPropertyAccessor<T> getAccessorForOwner(T owner)
      Returns a PersistentPropertyAccessor for the current property's owning value.
      Parameters:
      owner - must not be null.
      Returns:
      will never be null.
      Since:
      2.3