Module spring.data.commons
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, Christoph Strobl
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classstatic class -
Method Summary
Modifier and TypeMethodDescriptionClass<?>default booleanAttempt to find theMethodby name and exact parameters.static <T> RepositoryFragment<T>implemented(Class<T> interfaceClass, T implementation) static <T> RepositoryFragment<T>implemented(T implementation) Create an implementedRepositoryFragmentbacked by theimplementationobject.methods()static <T> RepositoryFragment<T>structural(Class<T> interfaceOrImplementation) Create a structuralRepositoryFragmentgiveninterfaceOrImplementation.withImplementation(T implementation) Implement a structuralRepositoryFragmentgiven itsimplementationobject.
-
Method Details
-
implemented
Create an implementedRepositoryFragmentbacked by theimplementationobject.- Parameters:
implementation- must not be null.- Returns:
-
implemented
- Parameters:
implementation- must not be null.- Returns:
-
structural
Create a structuralRepositoryFragmentgiveninterfaceOrImplementation.- Parameters:
interfaceOrImplementation- must not be null.- Returns:
-
hasMethod
Attempt to find theMethodby 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
- Returns:
- the optional implementation. Only available for implemented fragments. Structural fragments return always
Optional.empty().
-
methods
- Returns:
- a
Streamof methods exposed by thisRepositoryFragment.
-
getSignatureContributor
Class<?> getSignatureContributor()- Returns:
- the class/interface providing signatures for this
RepositoryFragment.
-
withImplementation
Implement a structuralRepositoryFragmentgiven itsimplementationobject. Returns an implementedRepositoryFragment.- Parameters:
implementation- must not be null.- Returns:
- a new implemented
RepositoryFragmentforimplementation.
-