-
Notifications
You must be signed in to change notification settings - Fork 515
Expand file tree
/
Copy pathPathSelectors.java
More file actions
52 lines (46 loc) · 1.26 KB
/
PathSelectors.java
File metadata and controls
52 lines (46 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package com.spring4all.swagger;
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
import org.springframework.util.AntPathMatcher;
public class PathSelectors {
private PathSelectors() {
throw new UnsupportedOperationException();
}
/**
* Any path satisfies this condition
*
* @return predicate that is always true
*/
public static Predicate<String> any() {
return Predicates.alwaysTrue();
}
/**
* No path satisfies this condition
*
* @return predicate that is always false
*/
public static Predicate<String> none() {
return Predicates.alwaysFalse();
}
/**
* Predicate that evaluates the supplied regular expression
*
* @param pathRegex - regex
* @return predicate that matches a particular regex
*/
public static Predicate<String> regex(final String pathRegex) {
return input -> input.matches(pathRegex);
}
/**
* Predicate that evaluates the supplied ant pattern
*
* @param antPattern - ant Pattern
* @return predicate that matches a particular ant pattern
*/
public static Predicate<String> ant(final String antPattern) {
return input -> {
AntPathMatcher matcher = new AntPathMatcher();
return matcher.match(antPattern, input);
};
}
}