org.springframework.data.mapping.context

## Interface MappingContext<E extends PersistentEntity<?,P>,P extends PersistentProperty<P>>

All Known Implementing Classes:
  AbstractMappingContext

    public interface MappingContext<E extends PersistentEntity<?,P>,P extends PersistentProperty<P>>

This interface defines the overall context including all known PersistentEntity instances and methods to obtain instances on demand. it is used internally to establish associations between entities and also at runtime to obtain entities by name.

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

### Method Summary

All Methods Instance Methods Abstract Methods Default Methods
`<T> PersistentPropertyPaths<T,P>` `findPersistentPropertyPaths(Class<T> type, Predicate<? super P> predicate)` Returns all `PersistentPropertyPath`s pointing to properties on the given type that match the given `Predicate`.
`Collection<TypeInformation<?>>` `getManagedTypes()` Returns the `TypeInformation`s for all `PersistentEntity`s in the `MappingContext`.
`Collection<E>` `getPersistentEntities()` Returns all `PersistentEntity`s held in the context.
`E` `getPersistentEntity(Class<?> type)` Returns a `PersistentEntity` for the given `Class`.
`E` `getPersistentEntity(P persistentProperty)` Returns the `PersistentEntity` mapped by the given `PersistentProperty`.
`E` `getPersistentEntity(TypeInformation<?> type)` Returns a `PersistentEntity` for the given `TypeInformation`.
`PersistentPropertyPath<P>` `getPersistentPropertyPath(PropertyPath propertyPath)` Returns all `PersistentProperty`s for the given path expression based on the given `PropertyPath`.
`PersistentPropertyPath<P>` `getPersistentPropertyPath(String propertyPath, Class<?> type)` Returns all `PersistentProperty`s for the given dot path notation based on the given type.
`default E` `getRequiredPersistentEntity(Class<?> type)` Returns a required `PersistentEntity` for the given `Class`.
`default E` `getRequiredPersistentEntity(P persistentProperty)` Returns the `PersistentEntity` mapped by the given `PersistentProperty`.
`default E` `getRequiredPersistentEntity(TypeInformation<?> type)` Returns a `PersistentEntity` for the given `TypeInformation`.
`boolean` `hasPersistentEntityFor(Class<?> type)` Returns whether the `MappingContext` currently contains a `PersistentEntity` for the type.

### Method Detail

#### getPersistentEntities

    Collection<E> getPersistentEntities()

Returns all `PersistentEntity`s held in the context.

Returns:
  never null.

#### getPersistentEntity

    @Nullable
    E getPersistentEntity(Class<?> type)

Returns a `PersistentEntity` for the given `Class`. Will return `null` for types that are considered simple ones.

Parameters:
  `type` - must not be null.
Returns:
  null if no `PersistentEntity` found for type.
See Also:
  `SimpleTypeHolder.isSimpleType(Class)`

#### getRequiredPersistentEntity

    default E getRequiredPersistentEntity(Class<?> type)
                                   throws MappingException

Returns a required `PersistentEntity` for the given `Class`. Will throw `IllegalArgumentException` for types that are considered simple ones.

Parameters:
  `type` - must not be null.
Returns:
  never null.
Throws:
  `MappingException` - when no `PersistentEntity` can be found for given type.
Since:
  2.0
See Also:
  `SimpleTypeHolder.isSimpleType(Class)`

#### hasPersistentEntityFor

    boolean hasPersistentEntityFor(Class<?> type)

Returns whether the `MappingContext` currently contains a `PersistentEntity` for the type.

Parameters:
  `type` - must not be null.
Returns:
  true if `PersistentEntity` present for given type.
Since:
  1.8

#### getPersistentEntity

    @Nullable
    E getPersistentEntity(TypeInformation<?> type)

Returns a `PersistentEntity` for the given `TypeInformation`. Will return `null` for types that are considered simple ones.

Parameters:
  `type` - must not be null.
Returns:
  null if no `PersistentEntity` found for `TypeInformation`.
See Also:
  `SimpleTypeHolder.isSimpleType(Class)`

#### getRequiredPersistentEntity

    default E getRequiredPersistentEntity(TypeInformation<?> type)
                                   throws MappingException

Returns a `PersistentEntity` for the given `TypeInformation`. Will throw `IllegalArgumentException` for types that are considered simple ones.

Parameters:
  `type` - must not be null.
Returns:
  never null.
Throws:
  `MappingException` - when no `PersistentEntity` can be found for given `TypeInformation`.
See Also:
  `SimpleTypeHolder.isSimpleType(Class)`

#### getPersistentEntity

    @Nullable
    E getPersistentEntity(P persistentProperty)

Returns the `PersistentEntity` mapped by the given `PersistentProperty`.

Parameters:
  `persistentProperty` - must not be null.
Returns:
  the `PersistentEntity` mapped by the given `PersistentProperty` or null if no `PersistentEntity` exists for it or the `PersistentProperty` does not refer to an entity (the type of the property is considered simple see `SimpleTypeHolder.isSimpleType(Class)`).

#### getRequiredPersistentEntity

    default E getRequiredPersistentEntity(P persistentProperty)
                                   throws MappingException

Returns the `PersistentEntity` mapped by the given `PersistentProperty`.

Parameters:
  `persistentProperty` - must not be null.
Returns:
  the `PersistentEntity` mapped by the given `PersistentProperty` or null if no `PersistentEntity` exists for it or the `PersistentProperty` does not refer to an entity (the type of the property is considered simple see `SimpleTypeHolder.isSimpleType(Class)`).
Throws:
  `MappingException` - when no `PersistentEntity` can be found for given `PersistentProperty`.

#### getPersistentPropertyPath

    PersistentPropertyPath<P> getPersistentPropertyPath(PropertyPath propertyPath)
                                                 throws InvalidPersistentPropertyPath

Returns all `PersistentProperty`s for the given path expression based on the given `PropertyPath`.

Parameters:
  `propertyPath` - must not be null.
Returns:
  the `PersistentPropertyPath` representing the given `PropertyPath`.
Throws:
  `InvalidPersistentPropertyPath` - in case not all of the segments of the given `PropertyPath` can be resolved.

#### getPersistentPropertyPath

    PersistentPropertyPath<P> getPersistentPropertyPath(String propertyPath,
                                                        Class<?> type)
                                                 throws InvalidPersistentPropertyPath

Returns all `PersistentProperty`s for the given dot path notation based on the given type.

Parameters:
  `propertyPath` - must not be null.
  `type` - must not be null.
Returns:
  the `PersistentPropertyPath` representing the given property path on the given type.
Throws:
  `InvalidPersistentPropertyPath` - in case not all of the segments of the given property path can be resolved.

#### findPersistentPropertyPaths

    <T> PersistentPropertyPaths<T,P> findPersistentPropertyPaths(Class<T> type,
                                                                 Predicate<? super P> predicate)

Returns all `PersistentPropertyPath`s pointing to properties on the given type that match the given `Predicate`. In case of circular references the detection will stop at the property that references a type that's already included in the path. Note, that is is a potentially expensive operation as results cannot be cached.

Parameters:
  `type` - must not be null.
  `predicate` - must not be null.
Returns:
Since:
  2.1

#### getManagedTypes

    Collection<TypeInformation<?>> getManagedTypes()

Returns the `TypeInformation`s for all `PersistentEntity`s in the `MappingContext`.

Returns:
  all `TypeInformation`s for the `PersistentEntity`s in the `MappingContext`.
Since:
  1.8