Class RepositoryOperationsMapping

java.lang.Object
org.springframework.data.couchbase.repository.config.RepositoryOperationsMapping

public class RepositoryOperationsMapping extends Object
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 Details

    • RepositoryOperationsMapping

      public RepositoryOperationsMapping(CouchbaseOperations defaultOperations)
      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 given CouchbaseOperations.
      Parameters:
      repositoryInterface - the repository interface Class.
      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 given CouchbaseOperations.
      Parameters:
      entityClass - the domain type's Class.
      couchbaseOperations - the CouchbaseOperations to use.
      Returns:
      the mapping, for chaining.
    • getDefault

      public CouchbaseOperations getDefault()
      Returns:
      the configured default CouchbaseOperations.
    • setDefault

      public RepositoryOperationsMapping setDefault(CouchbaseOperations aDefault)
      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 the MappingContext to use in repositories. It is extracted from the default CouchbaseOperations.
      Returns:
      the mapping context.
    • resolve

      public CouchbaseOperations resolve(Class<?> repositoryInterface, Class<?> domainType)
      Given a repository interface and its domain type, resolves which CouchbaseOperations 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.