org.springframework.data.repository.core.support

## Class DefaultCrudMethods

- java.lang.Object
- - org.springframework.data.repository.core.support.DefaultCrudMethods

All Implemented Interfaces:
  CrudMethods

    public class DefaultCrudMethods
    extends Object
    implements CrudMethods

Default implementation to discover CRUD methods based on the given `RepositoryMetadata`. Will detect methods exposed in `CrudRepository` but also hand crafted CRUD methods that are signature compatible with the ones on `CrudRepository`.

Since:
  1.6
Author:
  Oliver Gierke, Thomas Darimont

### Constructor Summary

Constructors
Constructor and Description
`DefaultCrudMethods(RepositoryMetadata metadata)` Creates a new `DefaultCrudMethods` using the given `RepositoryMetadata`.

### Method Summary

All Methods Instance Methods Concrete Methods
`Optional<Method>` `getDeleteMethod()` Returns the delete method of the repository.
`Optional<Method>` `getFindAllMethod()` Returns the find all method of the repository.
`Optional<Method>` `getFindOneMethod()` Returns the find one method of the repository.
`Optional<Method>` `getSaveMethod()` Returns the method to be used for saving entities.
`boolean` `hasDelete()` Returns whether the repository exposes a delete method.
`boolean` `hasFindAllMethod()` Returns whether the repository exposes a find all method at all.
`boolean` `hasFindOneMethod()` Returns whether the repository exposes a find one method.
`boolean` `hasSaveMethod()` Returns whether the repository exposes a save method at all.

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

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### DefaultCrudMethods

    public DefaultCrudMethods(RepositoryMetadata metadata)

Creates a new `DefaultCrudMethods` using the given `RepositoryMetadata`.

Parameters:
  `metadata` - must not be null.

### Method Detail

#### getSaveMethod

    public Optional<Method> getSaveMethod()

Description copied from interface: `CrudMethods`
Returns the method to be used for saving entities. Usually signature compatible to `CrudRepository.save(Object)`.

Specified by:
  `getSaveMethod` in interface `CrudMethods`
Returns:
  the method to save entities or `Optional.empty()` if none exposed.
See Also:
  `CrudMethods.hasSaveMethod()`

#### hasSaveMethod

    public boolean hasSaveMethod()

Description copied from interface: `CrudMethods`
Returns whether the repository exposes a save method at all.

Specified by:
  `hasSaveMethod` in interface `CrudMethods`
Returns:

#### getFindAllMethod

    public Optional<Method> getFindAllMethod()

Description copied from interface: `CrudMethods`
Returns the find all method of the repository. Implementations should prefer more detailed methods like `PagingAndSortingRepository`'s taking a `Pageable` or `Sort` instance.

Specified by:
  `getFindAllMethod` in interface `CrudMethods`
Returns:
  the find all method of the repository or `Optional.empty()` if not available.
See Also:
  `CrudMethods.hasFindAllMethod()`

#### hasFindAllMethod

    public boolean hasFindAllMethod()

Description copied from interface: `CrudMethods`
Returns whether the repository exposes a find all method at all.

Specified by:
  `hasFindAllMethod` in interface `CrudMethods`
Returns:

#### getFindOneMethod

    public Optional<Method> getFindOneMethod()

Description copied from interface: `CrudMethods`
Returns the find one method of the repository. Usually signature compatible to `CrudRepository.findById(Object)`

Specified by:
  `getFindOneMethod` in interface `CrudMethods`
Returns:
  the find one method of the repository or `Optional.empty()` if not available.
See Also:
  `CrudMethods.hasFindOneMethod()`

#### hasFindOneMethod

    public boolean hasFindOneMethod()

Description copied from interface: `CrudMethods`
Returns whether the repository exposes a find one method.

Specified by:
  `hasFindOneMethod` in interface `CrudMethods`
Returns:

#### hasDelete

    public boolean hasDelete()

Description copied from interface: `CrudMethods`
Returns whether the repository exposes a delete method.

Specified by:
  `hasDelete` in interface `CrudMethods`
Returns:

#### getDeleteMethod

    public Optional<Method> getDeleteMethod()

Description copied from interface: `CrudMethods`
Returns the delete method of the repository. Will prefer a delete-by-entity method over a delete-by-id method.

Specified by:
  `getDeleteMethod` in interface `CrudMethods`
Returns:
  the delete method of the repository or `Optional.empty()` if not available.
See Also:
  `CrudMethods.hasDelete()`