org.springframework.data.repository.core.support

## Interface RepositoryFragment<T>

All Known Implementing Classes:
  RepositoryFragment.ImplementedRepositoryFragment, RepositoryFragment.StructuralRepositoryFragment

    public interface RepositoryFragment<T>

Value object representing a repository fragment.

Repository fragments are individual parts that contribute method signatures. They are used to form a `RepositoryComposition`. Fragments can be purely structural or backed with an implementation.

`Structural` fragments are not backed by an implementation and are primarily used to discover the structure of a repository composition and to perform validations.

`Implemented` repository fragments consist of a signature contributor and the implementing object. A signature contributor may be `an interface` or `just the implementing object` providing the available signatures for a repository.

Fragments are immutable.

Since:
  2.0
Author:
  Mark Paluch
See Also:
  `RepositoryComposition`

### Nested Class Summary

Nested Classes
`static class` `RepositoryFragment.ImplementedRepositoryFragment<T>`
`static class` `RepositoryFragment.StructuralRepositoryFragment<T>`

### Method Summary

All Methods Static Methods Instance Methods Abstract Methods Default Methods
`default Optional<T>` `getImplementation()`
`Class<?>` `getSignatureContributor()`
`default boolean` `hasMethod(Method method)` Attempt to find the `Method` by name and exact parameters.
`static <T> RepositoryFragment<T>` `implemented(Class<T> interfaceClass, T implementation)` Create an implemented `RepositoryFragment` from a `interfaceClass` backed by the `implementation` object.
`static <T> RepositoryFragment<T>` `implemented(T implementation)` Create an implemented `RepositoryFragment` backed by the `implementation` object.
`default Stream<Method>` `methods()`
`static <T> RepositoryFragment<T>` `structural(Class<T> interfaceOrImplementation)` Create a structural `RepositoryFragment` given `interfaceOrImplementation`.
`RepositoryFragment<T>` `withImplementation(T implementation)` Implement a structural `RepositoryFragment` given its `implementation` object.

### Method Detail

#### implemented

    static <T> RepositoryFragment<T> implemented(T implementation)

Create an implemented `RepositoryFragment` backed by the `implementation` object.

Parameters:
  `implementation` - must not be null.
Returns:

#### implemented

    static <T> RepositoryFragment<T> implemented(Class<T> interfaceClass,
                                                 T implementation)

Create an implemented `RepositoryFragment` from a `interfaceClass` backed by the `implementation` object.

Parameters:
  `implementation` - must not be null.
Returns:

#### structural

    static <T> RepositoryFragment<T> structural(Class<T> interfaceOrImplementation)

Create a structural `RepositoryFragment` given `interfaceOrImplementation`.

Parameters:
  `interfaceOrImplementation` - must not be null.
Returns:

#### hasMethod

    default boolean hasMethod(Method method)

Attempt to find the `Method` by name and exact parameters. Returns true if the method was found or false otherwise.

Parameters:
  `method` - must not be null.
Returns:
  true if the method was found or false otherwise

#### getImplementation

    default Optional<T> getImplementation()

Returns:
  the optional implementation. Only available for implemented fragments. Structural fragments return always `Optional.empty()`.

#### methods

    default Stream<Method> methods()

Returns:
  a `Stream` of methods exposed by this `RepositoryFragment`.

#### getSignatureContributor

    Class<?> getSignatureContributor()

Returns:
  the class/interface providing signatures for this `RepositoryFragment`.

#### withImplementation

    RepositoryFragment<T> withImplementation(T implementation)

Implement a structural `RepositoryFragment` given its `implementation` object. Returns an implemented `RepositoryFragment`.

Parameters:
  `implementation` - must not be null.
Returns:
  a new implemented `RepositoryFragment` for `implementation`.