org.springframework.data.mapping.model

## Class AbstractPersistentProperty<P extends PersistentProperty<P>>

- java.lang.Object
- - org.springframework.data.mapping.model.AbstractPersistentProperty<P>

All Implemented Interfaces:
  PersistentProperty<P>

Direct Known Subclasses:
  AnnotationBasedPersistentProperty

    public abstract class AbstractPersistentProperty<P extends PersistentProperty<P>>
    extends Object
    implements PersistentProperty<P>

Simple implementation of `PersistentProperty`.

Author:
  Jon Brisbin, Oliver Gierke, Christoph Strobl, Mark Paluch

### Constructor Summary

Constructors
Constructor and Description
`AbstractPersistentProperty(Property property, PersistentEntity<?,P> owner, SimpleTypeHolder simpleTypeHolder)`

### Method Summary

All Methods Instance Methods Abstract Methods Concrete Methods
`protected abstract Association<P>` `createAssociation()`
`boolean` `equals(Object obj)`
`Class<?>` `getActualType()` Returns the actual type of the property.
`Association<P>` `getAssociation()`
`Class<?>` `getComponentType()` Returns the component type of the type if it is a `Collection`.
`Field` `getField()`
`Method` `getGetter()` Returns the getter method to access the property value if available.
`Class<?>` `getMapValueType()` Returns the type of the values if the property is a `Map`.
`String` `getName()` The name of the property
`PersistentEntity<?,P>` `getOwner()` Returns the `PersistentEntity` owning the current `PersistentProperty`.
`Iterable<? extends TypeInformation<?>>` `getPersistentEntityTypes()` Returns the `TypeInformation` if the property references a `PersistentEntity`.
`protected Property` `getProperty()`
`Class<?>` `getRawType()` Returns the raw type as it's pulled from from the reflected property.
`Method` `getSetter()` Returns the setter method to set a property value.
`String` `getSpelExpression()`
`Class<?>` `getType()` The type of the property
`TypeInformation<?>` `getTypeInformation()` Returns the `TypeInformation` of the property.
`Method` `getWither()` Returns the with `Method` to set a property value on a new object instance.
`int` `hashCode()`
`boolean` `isArray()` Returns whether the property is an array.
`boolean` `isAssociation()` Returns whether the property is an `Association`.
`boolean` `isCollectionLike()` Returns whether the property is a `Collection`, `Iterable` or an array.
`boolean` `isEntity()` Returns whether the type of the `PersistentProperty` is actually to be regarded as `PersistentEntity` in turn.
`boolean` `isImmutable()` Returns whether the current property is immutable, i.e. if there is no setter or the backing `Field` is `final`.
`boolean` `isMap()` Returns whether the property is a `Map`.
`boolean` `isTransient()` Returns whether the property is transient.
`boolean` `isWritable()` Returns whether the current property is writable, i.e. if the value held for it shall be written to the data store.
`String` `toString()`
`boolean` `usePropertyAccess()` Returns whether property access shall be used for reading the property value.

### Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

### Methods inherited from interface org.springframework.data.mapping.PersistentProperty

`findAnnotation, findPropertyOrOwnerAnnotation, getAccessorForOwner, getAssociationTargetType, getRequiredAnnotation, getRequiredAssociation, getRequiredField, getRequiredGetter, getRequiredSetter, getRequiredWither, hasActualTypeAnnotation, isAnnotationPresent, isIdProperty, isVersionProperty`

### Constructor Detail

#### AbstractPersistentProperty

    public AbstractPersistentProperty(Property property,
                                      PersistentEntity<?,P> owner,
                                      SimpleTypeHolder simpleTypeHolder)

### Method Detail

#### createAssociation

    protected abstract Association<P> createAssociation()

#### getOwner

    public PersistentEntity<?,P> getOwner()

Description copied from interface: `PersistentProperty`
Returns the `PersistentEntity` owning the current `PersistentProperty`.

Specified by:
  `getOwner` in interface `PersistentProperty<P extends PersistentProperty<P>>`
Returns:
  never null.

#### getName

    public String getName()

Description copied from interface: `PersistentProperty`
The name of the property

Specified by:
  `getName` in interface `PersistentProperty<P extends PersistentProperty<P>>`
Returns:
  The property name

#### getType

    public Class<?> getType()

Description copied from interface: `PersistentProperty`
The type of the property

Specified by:
  `getType` in interface `PersistentProperty<P extends PersistentProperty<P>>`
Returns:
  The property type

#### getRawType

    public Class<?> getRawType()

Description copied from interface: `PersistentProperty`
Returns the raw type as it's pulled from from the reflected property.

Specified by:
  `getRawType` in interface `PersistentProperty<P extends PersistentProperty<P>>`
Returns:
  the raw type of the property.

#### getTypeInformation

    public TypeInformation<?> getTypeInformation()

Description copied from interface: `PersistentProperty`
Returns the `TypeInformation` of the property.

Specified by:
  `getTypeInformation` in interface `PersistentProperty<P extends PersistentProperty<P>>`
Returns:

#### getPersistentEntityTypes

    public Iterable<? extends TypeInformation<?>> getPersistentEntityTypes()

Description copied from interface: `PersistentProperty`
Returns the `TypeInformation` if the property references a `PersistentEntity`. Will return null in case it refers to a simple type. Will return `Collection`'s component type or the `Map`'s value type transparently.

Specified by:
  `getPersistentEntityTypes` in interface `PersistentProperty<P extends PersistentProperty<P>>`
Returns:

#### getGetter

    public Method getGetter()

Description copied from interface: `PersistentProperty`
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.

Specified by:
  `getGetter` in interface `PersistentProperty<P extends PersistentProperty<P>>`
Returns:
  the getter method to access the property value if available, otherwise null.

#### getSetter

    public Method getSetter()

Description copied from interface: `PersistentProperty`
Returns the setter method to set a property value. Might return null in case there is no setter available.

Specified by:
  `getSetter` in interface `PersistentProperty<P extends PersistentProperty<P>>`
Returns:
  the setter method to set a property value if available, otherwise null.

#### getWither

    public Method getWither()

Description copied from interface: `PersistentProperty`
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);
            }
     }

Specified by:
  `getWither` in interface `PersistentProperty<P extends PersistentProperty<P>>`
Returns:
  the with `Method` to set a property value on a new object instance if available, otherwise null.

#### getField

    @Nullable
    public Field getField()

Specified by:
  `getField` in interface `PersistentProperty<P extends PersistentProperty<P>>`

#### getSpelExpression

    @Nullable
    public String getSpelExpression()

Specified by:
  `getSpelExpression` in interface `PersistentProperty<P extends PersistentProperty<P>>`
Returns:
  null if no expression defined.

#### isTransient

    public boolean isTransient()

Description copied from interface: `PersistentProperty`
Returns whether the property is transient.

Specified by:
  `isTransient` in interface `PersistentProperty<P extends PersistentProperty<P>>`
Returns:

#### isWritable

    public boolean isWritable()

Description copied from interface: `PersistentProperty`
Returns whether the current property is writable, i.e. if the value held for it shall be written to the data store.

Specified by:
  `isWritable` in interface `PersistentProperty<P extends PersistentProperty<P>>`
Returns:

#### isImmutable

    public boolean isImmutable()

Description copied from interface: `PersistentProperty`
Returns whether the current property is immutable, i.e. if there is no setter or the backing `Field` is `final`.

Specified by:
  `isImmutable` in interface `PersistentProperty<P extends PersistentProperty<P>>`
Returns:
See Also:
  `Modifier.isFinal(int)`

#### isAssociation

    public boolean isAssociation()

Description copied from interface: `PersistentProperty`
Returns whether the property is an `Association`.

Specified by:
  `isAssociation` in interface `PersistentProperty<P extends PersistentProperty<P>>`
Returns:

#### getAssociation

    @Nullable
    public Association<P> getAssociation()

Specified by:
  `getAssociation` in interface `PersistentProperty<P extends PersistentProperty<P>>`
Returns:
  null if property is not part of an `Association`.

#### isCollectionLike

    public boolean isCollectionLike()

Description copied from interface: `PersistentProperty`
Returns whether the property is a `Collection`, `Iterable` or an array.

Specified by:
  `isCollectionLike` in interface `PersistentProperty<P extends PersistentProperty<P>>`
Returns:

#### isMap

    public boolean isMap()

Description copied from interface: `PersistentProperty`
Returns whether the property is a `Map`.

Specified by:
  `isMap` in interface `PersistentProperty<P extends PersistentProperty<P>>`
Returns:

#### isArray

    public boolean isArray()

Description copied from interface: `PersistentProperty`
Returns whether the property is an array.

Specified by:
  `isArray` in interface `PersistentProperty<P extends PersistentProperty<P>>`
Returns:

#### isEntity

    public boolean isEntity()

Description copied from interface: `PersistentProperty`
Returns whether the type of the `PersistentProperty` is actually to be regarded as `PersistentEntity` in turn.

Specified by:
  `isEntity` in interface `PersistentProperty<P extends PersistentProperty<P>>`
Returns:
  true a `PersistentEntity`.

#### getComponentType

    @Nullable
    public Class<?> getComponentType()

Description copied from interface: `PersistentProperty`
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`.

Specified by:
  `getComponentType` in interface `PersistentProperty<P extends PersistentProperty<P>>`
Returns:
  the component type, the map's key type or null if neither `Collection` nor `Map`.

#### getMapValueType

    @Nullable
    public Class<?> getMapValueType()

Description copied from interface: `PersistentProperty`
Returns the type of the values if the property is a `Map`.

Specified by:
  `getMapValueType` in interface `PersistentProperty<P extends PersistentProperty<P>>`
Returns:
  the map's value type or null if no `Map`

#### getActualType

    public Class<?> getActualType()

Description copied from interface: `PersistentProperty`
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.

Specified by:
  `getActualType` in interface `PersistentProperty<P extends PersistentProperty<P>>`
Returns:

#### usePropertyAccess

    public boolean usePropertyAccess()

Description copied from interface: `PersistentProperty`
Returns whether property access shall be used for reading the property value. This means it will use the getter instead of field access.

Specified by:
  `usePropertyAccess` in interface `PersistentProperty<P extends PersistentProperty<P>>`
Returns:

#### getProperty

    protected Property getProperty()

#### equals

    public boolean equals(@Nullable
                          Object obj)

Overrides:
  `equals` in class `Object`

#### hashCode

    public int hashCode()

Overrides:
  `hashCode` in class `Object`

#### toString

    public String toString()

Overrides:
  `toString` in class `Object`