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
Nested ClassesModifier and TypeInterfaceDescriptionstatic classA generic property matcher that specifiesstring matchingand case sensitivity.static classPredefined property matchers to create aExampleMatcher.GenericPropertyMatcher.static interfaceCallback to configure a matcher.static enumThe match modes to expose so that clients can find about how to concatenate the predicates.static enumstatic enumNull handling for creating criterion out of anExample.static classDefine specific property handling for a Dot-Path.static classDefine specific property handling for Dot-Paths.static interfaceAllows to transform the property value before it is used in the query.static enumMatch modes for treatment ofStringvalues. -
Method Summary
Modifier and TypeMethodDescriptionGet definedExampleMatcher.StringMatcher.Get the match mode of theExampleMatcher.Get defined null handling.default booleanReturns whether all of the predicates of theExampleare supposed to match.default booleanReturns whether it's sufficient that any of the predicates of theExamplematch.booleandefault booleanisIgnoredPath(String path) static ExampleMatchermatching()Create a newExampleMatcherincluding all non-null properties by default matching all predicates derived from the example.static ExampleMatcherCreate a newExampleMatcherincluding all non-null properties by default matching all predicates derived from the example.static ExampleMatcherCreate a newExampleMatcherincluding all non-null properties by default matching any predicate derived from the example.default ExampleMatcherReturns a copy of thisExampleMatcherwith ignoring case sensitivity by default.withIgnoreCase(boolean defaultIgnoreCase) Returns a copy of thisExampleMatcherwithdefaultIgnoreCase.withIgnoreCase(String... propertyPaths) Returns a copy of thisExampleMatcherwith ignore case sensitivity for thepropertyPaths.default ExampleMatcherReturns a copy of thisExampleMatcherwith treatment for null values ofExampleMatcher.NullHandler.IGNORE.withIgnorePaths(String... ignoredPaths) Returns a copy of thisExampleMatcherwith the specifiedpropertyPaths.default ExampleMatcherReturns a copy of thisExampleMatcherwith treatment for null values ofExampleMatcher.NullHandler.INCLUDE.withMatcher(String propertyPath, ExampleMatcher.GenericPropertyMatcher genericPropertyMatcher) Returns a copy of thisExampleMatcherwith the specifiedGenericPropertyMatcherfor thepropertyPath.default ExampleMatcherwithMatcher(String propertyPath, ExampleMatcher.MatcherConfigurer<ExampleMatcher.GenericPropertyMatcher> matcherConfigurer) Returns a copy of thisExampleMatcherwith the specifiedGenericPropertyMatcherfor thepropertyPath.withNullHandler(ExampleMatcher.NullHandler nullHandler) Returns a copy of thisExampleMatcherwith the specifiednullHandler.withStringMatcher(ExampleMatcher.StringMatcher defaultStringMatcher) Returns a copy of thisExampleMatcherwith the specified string matching ofdefaultStringMatcher.withTransformer(String propertyPath, ExampleMatcher.PropertyValueTransformer propertyValueTransformer) Returns a copy of thisExampleMatcherwith the specifiedPropertyValueTransformerfor thepropertyPath.
-
Method Details
-
matching
Create a newExampleMatcherincluding all non-null properties by default matching all predicates derived from the example.- Returns:
- new instance of
ExampleMatcher. - See Also:
-
matchingAny
Create a newExampleMatcherincluding all non-null properties by default matching any predicate derived from the example.- Returns:
- new instance of
ExampleMatcher.
-
matchingAll
Create a newExampleMatcherincluding all non-null properties by default matching all predicates derived from the example.- Returns:
- new instance of
ExampleMatcher.
-
withIgnorePaths
Returns a copy of thisExampleMatcherwith 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 thisExampleMatcherwith 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 thisExampleMatcherwith 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 thisExampleMatcherwithdefaultIgnoreCase. 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 thisExampleMatcherwith the specifiedGenericPropertyMatcherfor 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 thisExampleMatcherwith the specifiedGenericPropertyMatcherfor 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 thisExampleMatcherwith the specifiedPropertyValueTransformerfor thepropertyPath.- Parameters:
propertyPath- must not be null.propertyValueTransformer- must not be null.- Returns:
- new instance of
ExampleMatcher.
-
withIgnoreCase
Returns a copy of thisExampleMatcherwith 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 thisExampleMatcherwith 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 thisExampleMatcherwith 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 thisExampleMatcherwith 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
Stringshould 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
Setof ignored paths.
-
getPropertySpecifiers
ExampleMatcher.PropertySpecifiers getPropertySpecifiers()- Returns:
- the
ExampleMatcher.PropertySpecifierswithin theExampleMatcher.
-
isAllMatching
default boolean isAllMatching()Returns whether all of the predicates of theExampleare supposed to match. If false is returned, it's sufficient if any of the predicates derived from theExamplematch.- Returns:
- whether all of the predicates of the
Exampleare supposed to match or any of them is sufficient.
-
isAnyMatching
default boolean isAnyMatching()Returns whether it's sufficient that any of the predicates of theExamplematch. 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
Examplematch or all need to match.
-
getMatchMode
ExampleMatcher.MatchMode getMatchMode()Get the match mode of theExampleMatcher.- Returns:
- never null.
- Since:
- 2.0
-