org.springframework.data.repository.support

## Interface RepositoryInvoker

All Superinterfaces:
  RepositoryInvocationInformation

All Known Implementing Classes:
  QuerydslRepositoryInvokerAdapter

    public interface RepositoryInvoker
    extends RepositoryInvocationInformation

API to invoke (CRUD) methods on Spring Data repository instances independently of the base interface they expose. Clients should check the availability of the methods before invoking them by using the methods of `RepositoryInvocationInformation`.

Since:
  1.10
Author:
  Oliver Gierke

### Method Summary

All Methods Instance Methods Abstract Methods
`void` `invokeDeleteById(Object id)` Invokes the method equivalent to `CrudRepository.deleteById(Object)`.

`Iterable<Object>`

`invokeFindAll(Pageable pageable)`
Invokes the find-all method of the underlying repository using the method taking a `Pageable` as parameter if available (i.e. the equivalent to `PagingAndSortingRepository.findAll(Pageable)`), using the method taking a `Sort` if available (i.e. the equivalent to `PagingAndSortingRepository.findAll(Sort)` by extracting the `Sort` contained in the given `Pageable`) or the plain equivalent to `CrudRepository.findAll()`.

`Iterable<Object>` `invokeFindAll(Sort sort)` Invokes the find-all method of the underlying repository using the method taking a `Sort` as parameter if available (i.e. the equivalent to `PagingAndSortingRepository.findAll(Sort)`) or the plain equivalent to `CrudRepository.findAll()`.
`<T> Optional<T>` `invokeFindById(Object id)` Invokes the method equivalent to `CrudRepository.findById(Object)`.
`Optional<Object>` `invokeQueryMethod(Method method, MultiValueMap<String,? extends Object> parameters, Pageable pageable, Sort sort)` Invokes the query method backed by the given `Method` using the given parameters, `Pageable` and `Sort`.
`<T> T` `invokeSave(T object)` Invokes the method equivalent to `CrudRepository.save(Object)` on the repository.

### Methods inherited from interface org.springframework.data.repository.support.RepositoryInvocationInformation

`hasDeleteMethod, hasFindAllMethod, hasFindOneMethod, hasSaveMethod`

### Method Detail

#### invokeSave

    <T> T invokeSave(T object)

Invokes the method equivalent to `CrudRepository.save(Object)` on the repository.

Parameters:
  `object` -
Returns:
  the result of the invocation of the save method
Throws:
  `IllegalStateException` - if the repository does not expose a save method.

#### invokeFindById

    <T> Optional<T> invokeFindById(Object id)

Invokes the method equivalent to `CrudRepository.findById(Object)`.

Parameters:
  `id` - must not be null.
Returns:
  the entity with the given id.
Throws:
  `IllegalStateException` - if the repository does not expose a find-one-method.

#### invokeFindAll

    Iterable<Object> invokeFindAll(Pageable pageable)

Invokes the find-all method of the underlying repository using the method taking a `Pageable` as parameter if available (i.e. the equivalent to `PagingAndSortingRepository.findAll(Pageable)`), using the method taking a `Sort` if available (i.e. the equivalent to `PagingAndSortingRepository.findAll(Sort)` by extracting the `Sort` contained in the given `Pageable`) or the plain equivalent to `CrudRepository.findAll()`.

Parameters:
  `pageable` - can be null.
Returns:
  the result of the invocation of the find-all method.
Throws:
  `IllegalStateException` - if the repository does not expose a find-all-method.

#### invokeFindAll

    Iterable<Object> invokeFindAll(Sort sort)

Invokes the find-all method of the underlying repository using the method taking a `Sort` as parameter if available (i.e. the equivalent to `PagingAndSortingRepository.findAll(Sort)`) or the plain equivalent to `CrudRepository.findAll()`.

Parameters:
  `pageable` - can be null.
Returns:
  the result of the invocation of the find-all method.
Throws:
  `IllegalStateException` - if the repository does not expose a find-all-method.

#### invokeDeleteById

    void invokeDeleteById(Object id)

Invokes the method equivalent to `CrudRepository.deleteById(Object)`. The given id is assumed to be of a type convertible into the actual identifier type of the backing repository.

Parameters:
  `id` - must not be null.
Throws:
  `{@link` - IllegalStateException} if the repository does not expose a delete-method.

#### invokeQueryMethod

    Optional<Object> invokeQueryMethod(Method method,
                                       MultiValueMap<String,? extends Object> parameters,
                                       Pageable pageable,
                                       Sort sort)

Invokes the query method backed by the given `Method` using the given parameters, `Pageable` and `Sort`.

Parameters:
  `method` - must not be null.
  `parameters` - must not be null.
  `pageable` - must not be null.
  `sort` - must not be null.
Returns:
  the result of the invoked query method.
Since:
  1.11