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
- See Also:
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic class
static class
-
Method Summary
Modifier and TypeMethodDescriptionClass<?>
default boolean
Attempt to find theMethod
by name and exact parameters.static <T> RepositoryFragment<T>
implemented
(Class<T> interfaceClass, T implementation) static <T> RepositoryFragment<T>
implemented
(T implementation) Create an implementedRepositoryFragment
backed by theimplementation
object.methods()
static <T> RepositoryFragment<T>
structural
(Class<T> interfaceOrImplementation) Create a structuralRepositoryFragment
giveninterfaceOrImplementation
.withImplementation
(T implementation) Implement a structuralRepositoryFragment
given itsimplementation
object.
-
Method Details
-
implemented
Create an implementedRepositoryFragment
backed by theimplementation
object.- Parameters:
implementation
- must not be null.- Returns:
-
implemented
- Parameters:
implementation
- must not be null.- Returns:
-
structural
Create a structuralRepositoryFragment
giveninterfaceOrImplementation
.- Parameters:
interfaceOrImplementation
- must not be null.- Returns:
-
hasMethod
Attempt to find theMethod
by 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
Stream
of methods exposed by thisRepositoryFragment
.
-
getSignatureContributor
Class<?> getSignatureContributor()- Returns:
- the class/interface providing signatures for this
RepositoryFragment
.
-
withImplementation
Implement a structuralRepositoryFragment
given itsimplementation
object. Returns an implementedRepositoryFragment
.- Parameters:
implementation
- must not be null.- Returns:
- a new implemented
RepositoryFragment
forimplementation
.
-