Package org.springframework.data.domain
Interface ExampleMatcher
public interface ExampleMatcher
Specification for property path matching to use in query by example (QBE). An
ExampleMatcher
can be created
for a object type
. Instances of ExampleMatcher
can be either matchingAll()
or
matchingAny()
and settings can be tuned with...
methods in a fluent style. with...
methods
return a copy of the ExampleMatcher
instance with the specified setting. Null-handling defaults to
ExampleMatcher.NullHandler.IGNORE
and case-sensitive ExampleMatcher.StringMatcher.DEFAULT
string matching.
This class is immutable.
- Since:
- 1.12
- Author:
- Christoph Strobl, Mark Paluch, Oliver Gierke, Jens Schauder
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic class
A generic property matcher that specifiesstring matching
and case sensitivity.static class
Predefined property matchers to create aExampleMatcher.GenericPropertyMatcher
.static interface
Callback to configure a matcher.static enum
The match modes to expose so that clients can find about how to concatenate the predicates.static enum
static enum
Null handling for creating criterion out of anExample
.static class
Define specific property handling for a Dot-Path.static class
Define specific property handling for Dot-Paths.static interface
Allows to transform the property value before it is used in the query.static enum
Match modes for treatment ofString
values. -
Method Summary
Modifier and TypeMethodDescriptionGet definedExampleMatcher.StringMatcher
.Get the match mode of theExampleMatcher
.Get defined null handling.default boolean
Returns whether all of the predicates of theExample
are supposed to match.default boolean
Returns whether it's sufficient that any of the predicates of theExample
match.boolean
default boolean
isIgnoredPath
(String path) static ExampleMatcher
matching()
Create a newExampleMatcher
including all non-null properties by default matching all predicates derived from the example.static ExampleMatcher
Create a newExampleMatcher
including all non-null properties by default matching all predicates derived from the example.static ExampleMatcher
Create a newExampleMatcher
including all non-null properties by default matching any predicate derived from the example.default ExampleMatcher
Returns a copy of thisExampleMatcher
with ignoring case sensitivity by default.withIgnoreCase
(boolean defaultIgnoreCase) Returns a copy of thisExampleMatcher
withdefaultIgnoreCase
.withIgnoreCase
(String... propertyPaths) Returns a copy of thisExampleMatcher
with ignore case sensitivity for thepropertyPaths
.default ExampleMatcher
Returns a copy of thisExampleMatcher
with treatment for null values ofExampleMatcher.NullHandler.IGNORE
.withIgnorePaths
(String... ignoredPaths) Returns a copy of thisExampleMatcher
with the specifiedpropertyPaths
.default ExampleMatcher
Returns a copy of thisExampleMatcher
with treatment for null values ofExampleMatcher.NullHandler.INCLUDE
.withMatcher
(String propertyPath, ExampleMatcher.GenericPropertyMatcher genericPropertyMatcher) Returns a copy of thisExampleMatcher
with the specifiedGenericPropertyMatcher
for thepropertyPath
.default ExampleMatcher
withMatcher
(String propertyPath, ExampleMatcher.MatcherConfigurer<ExampleMatcher.GenericPropertyMatcher> matcherConfigurer) Returns a copy of thisExampleMatcher
with the specifiedGenericPropertyMatcher
for thepropertyPath
.withNullHandler
(ExampleMatcher.NullHandler nullHandler) Returns a copy of thisExampleMatcher
with the specifiednullHandler
.withStringMatcher
(ExampleMatcher.StringMatcher defaultStringMatcher) Returns a copy of thisExampleMatcher
with the specified string matching ofdefaultStringMatcher
.withTransformer
(String propertyPath, ExampleMatcher.PropertyValueTransformer propertyValueTransformer) Returns a copy of thisExampleMatcher
with the specifiedPropertyValueTransformer
for thepropertyPath
.
-
Method Details
-
matching
Create a newExampleMatcher
including all non-null properties by default matching all predicates derived from the example.- Returns:
- new instance of
ExampleMatcher
. - See Also:
-
matchingAny
Create a newExampleMatcher
including all non-null properties by default matching any predicate derived from the example.- Returns:
- new instance of
ExampleMatcher
.
-
matchingAll
Create a newExampleMatcher
including all non-null properties by default matching all predicates derived from the example.- Returns:
- new instance of
ExampleMatcher
.
-
withIgnorePaths
Returns a copy of thisExampleMatcher
with the specifiedpropertyPaths
. This instance is immutable and unaffected by this method call.- Parameters:
ignoredPaths
- must not be null and not empty.- Returns:
- new instance of
ExampleMatcher
.
-
withStringMatcher
Returns a copy of thisExampleMatcher
with the specified string matching ofdefaultStringMatcher
. This instance is immutable and unaffected by this method call.- Parameters:
defaultStringMatcher
- must not be null.- Returns:
- new instance of
ExampleMatcher
.
-
withIgnoreCase
Returns a copy of thisExampleMatcher
with ignoring case sensitivity by default. This instance is immutable and unaffected by this method call.- Returns:
- new instance of
ExampleMatcher
.
-
withIgnoreCase
Returns a copy of thisExampleMatcher
withdefaultIgnoreCase
. This instance is immutable and unaffected by this method call.- Parameters:
defaultIgnoreCase
-- Returns:
- new instance of
ExampleMatcher
.
-
withMatcher
default ExampleMatcher withMatcher(String propertyPath, ExampleMatcher.MatcherConfigurer<ExampleMatcher.GenericPropertyMatcher> matcherConfigurer) Returns a copy of thisExampleMatcher
with the specifiedGenericPropertyMatcher
for thepropertyPath
. This instance is immutable and unaffected by this method call.- Parameters:
propertyPath
- must not be null.matcherConfigurer
- callback to configure aExampleMatcher.GenericPropertyMatcher
, must not be null.- Returns:
- new instance of
ExampleMatcher
.
-
withMatcher
ExampleMatcher withMatcher(String propertyPath, ExampleMatcher.GenericPropertyMatcher genericPropertyMatcher) Returns a copy of thisExampleMatcher
with the specifiedGenericPropertyMatcher
for thepropertyPath
. This instance is immutable and unaffected by this method call.- Parameters:
propertyPath
- must not be null.genericPropertyMatcher
- callback to configure aExampleMatcher.GenericPropertyMatcher
, must not be null.- Returns:
- new instance of
ExampleMatcher
.
-
withTransformer
ExampleMatcher withTransformer(String propertyPath, ExampleMatcher.PropertyValueTransformer propertyValueTransformer) Returns a copy of thisExampleMatcher
with the specifiedPropertyValueTransformer
for thepropertyPath
.- Parameters:
propertyPath
- must not be null.propertyValueTransformer
- must not be null.- Returns:
- new instance of
ExampleMatcher
.
-
withIgnoreCase
Returns a copy of thisExampleMatcher
with ignore case sensitivity for thepropertyPaths
. This instance is immutable and unaffected by this method call.- Parameters:
propertyPaths
- must not be null and not empty.- Returns:
- new instance of
ExampleMatcher
.
-
withIncludeNullValues
Returns a copy of thisExampleMatcher
with treatment for null values ofExampleMatcher.NullHandler.INCLUDE
. This instance is immutable and unaffected by this method call.- Returns:
- new instance of
ExampleMatcher
.
-
withIgnoreNullValues
Returns a copy of thisExampleMatcher
with treatment for null values ofExampleMatcher.NullHandler.IGNORE
. This instance is immutable and unaffected by this method call.- Returns:
- new instance of
ExampleMatcher
.
-
withNullHandler
Returns a copy of thisExampleMatcher
with the specifiednullHandler
. This instance is immutable and unaffected by this method call.- Parameters:
nullHandler
- must not be null.- Returns:
- new instance of
ExampleMatcher
.
-
getNullHandler
ExampleMatcher.NullHandler getNullHandler()Get defined null handling.- Returns:
- never null
-
getDefaultStringMatcher
ExampleMatcher.StringMatcher getDefaultStringMatcher()Get definedExampleMatcher.StringMatcher
.- Returns:
- never null.
-
isIgnoreCaseEnabled
boolean isIgnoreCaseEnabled()- Returns:
- true if
String
should be matched with ignore case option.
-
isIgnoredPath
- Parameters:
path
- must not be null.- Returns:
- return true if path was set to be ignored.
-
getIgnoredPaths
- Returns:
- unmodifiable
Set
of ignored paths.
-
getPropertySpecifiers
ExampleMatcher.PropertySpecifiers getPropertySpecifiers()- Returns:
- the
ExampleMatcher.PropertySpecifiers
within theExampleMatcher
.
-
isAllMatching
default boolean isAllMatching()Returns whether all of the predicates of theExample
are supposed to match. If false is returned, it's sufficient if any of the predicates derived from theExample
match.- Returns:
- whether all of the predicates of the
Example
are supposed to match or any of them is sufficient.
-
isAnyMatching
default boolean isAnyMatching()Returns whether it's sufficient that any of the predicates of theExample
match. If false is returned, all predicates derived from the example need to match to produce results.- Returns:
- whether it's sufficient that any of the predicates of the
Example
match or all need to match.
-
getMatchMode
ExampleMatcher.MatchMode getMatchMode()Get the match mode of theExampleMatcher
.- Returns:
- never null.
- Since:
- 2.0
-