Class RepositoryOperationsMapping
java.lang.Object
org.springframework.data.couchbase.repository.config.RepositoryOperationsMapping
A utility class for configuration allowing to tell which
CouchbaseOperations
should be backing repositories.
Its fluent API allows to set that (in order of precedence) for specific repository interfaces, by repository domain
type or as a default fallback.- Author:
- Simon Baslé, Mark Paluch
-
Constructor Summary
ConstructorDescriptionRepositoryOperationsMapping
(CouchbaseOperations defaultOperations) Creates a new mapping, setting the default fallback to use by otherwise non mapped repositories. -
Method Summary
Modifier and TypeMethodDescriptionGet theMappingContext
to use in repositories.map
(Class<?> repositoryInterface, CouchbaseOperations couchbaseOperations) Add a highest priority mapping that will associate a specific repository interface with a givenCouchbaseOperations
.mapEntity
(Class<?> entityClass, CouchbaseOperations couchbaseOperations) Add a middle priority mapping that will associate any un-mapped repository that deals with the given domain type Class with a givenCouchbaseOperations
.Given a repository interface and its domain type, resolves whichCouchbaseOperations
it should be backed with.setDefault
(CouchbaseOperations aDefault) Change the default couchbase operations in an existing mapping.
-
Constructor Details
-
RepositoryOperationsMapping
Creates a new mapping, setting the default fallback to use by otherwise non mapped repositories.- Parameters:
defaultOperations
- the default fallback couchbase operations.
-
-
Method Details
-
map
public RepositoryOperationsMapping map(Class<?> repositoryInterface, CouchbaseOperations couchbaseOperations) Add a highest priority mapping that will associate a specific repository interface with a givenCouchbaseOperations
.- Parameters:
repositoryInterface
- the repository interfaceClass
.couchbaseOperations
- the CouchbaseOperations to use.- Returns:
- the mapping, for chaining.
-
mapEntity
public RepositoryOperationsMapping mapEntity(Class<?> entityClass, CouchbaseOperations couchbaseOperations) Add a middle priority mapping that will associate any un-mapped repository that deals with the given domain type Class with a givenCouchbaseOperations
.- Parameters:
entityClass
- the domain type'sClass
.couchbaseOperations
- the CouchbaseOperations to use.- Returns:
- the mapping, for chaining.
-
getDefault
- Returns:
- the configured default
CouchbaseOperations
.
-
setDefault
Change the default couchbase operations in an existing mapping.- Parameters:
aDefault
- the new default couchbase operations.- Returns:
- the mapping, for chaining.
-
getMappingContext
public MappingContext<? extends CouchbasePersistentEntity<?>,CouchbasePersistentProperty> getMappingContext()Get theMappingContext
to use in repositories. It is extracted from the defaultCouchbaseOperations
.- Returns:
- the mapping context.
-
resolve
Given a repository interface and its domain type, resolves whichCouchbaseOperations
it should be backed with. Starts by looking for a direct mapping to the interface, then a common mapping for the domain type, then falls back to the default CouchbaseOperations.- Parameters:
repositoryInterface
- the repository's interface.domainType
- the repository's domain type / entity.- Returns:
- the CouchbaseOperations to back the repository.
-