Package net.solarnetwork.util
Class MapPathMatcher
java.lang.Object
net.solarnetwork.util.MapPathMatcher
Match search filter against a nested map using paths for filter keys.
This utility tries to match a SearchFilter against a Map, by
treating each search filter key (the left-hand side of each filter
comparison) like a URL path that corresponds to an entry in the map. Each
path segment represents a map, possibly nested with the root map.
For example, given this JSON representation of a nested map structure:
{
"foo": {
"bar": 1,
"bim": "bam"
},
"pow": 2
}
then the filters (/foo/bar=1) and (/foo/bim=bam)
and (/pow=2) and (&(/foo/bar=1)(/pow<5))
would match while (/foo/bar>1) and (/foo/bim=no)
and (|(/foo/bar>1)(/pow>2)) would not.
Originally ported from the JavaScript objectPathMatcher class.
- Since:
- 1.67
- Version:
- 1.0
- Author:
- matt
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanTest if a filter matches the configured map.static booleanTest if a filter matches a map.static booleanmatches(Map<String, ?> map, SearchFilter filter) Test if a filter matches the configured map.booleanmatches(SearchFilter filter) Test if a filter matches the configured map.
-
Constructor Details
-
MapPathMatcher
Constructor.- Parameters:
map- the map root
-
-
Method Details
-
matches
Test if a filter matches a map.- Parameters:
map- the mapfilterText- the filter in text form- Returns:
- true if the filter matches
- See Also:
-
matches
Test if a filter matches the configured map.- Parameters:
map- the mapfilter- the filter to test for matches- Returns:
- true if the filter matches
-
matches
Test if a filter matches the configured map.- Parameters:
filterText- the filter in text form- Returns:
- true if the filter matches
- See Also:
-
matches
Test if a filter matches the configured map.- Parameters:
filter- the filter to test for matches- Returns:
- true if the filter matches
-