Package io.sundr.utils
Class Patterns
java.lang.Object
io.sundr.utils.Patterns
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classFluent API for pattern matching with explicit type control.static enumPattern type enumeration for explicit pattern type selection. -
Method Summary
Modifier and TypeMethodDescriptionstatic Patterns.PatternMatcherauto()Returns a PatternMatcher configured to auto-detect pattern type.static Patterns.PatternMatcherglob()Returns a PatternMatcher configured to use glob patterns explicitly.static StringglobToRegex(String glob) Converts a glob pattern to a regular expression.static booleanisExcluded(String target, String... excludes) static booleanisGlobPattern(String pattern) Determines if a pattern is a glob pattern or a regex pattern.static booleanisIncluded(String target, String... includes) static booleanmatchesGlob(String target, String glob) Matches a target string against a glob pattern.static booleanmatchesPattern(String target, String pattern) Checks if the target string matches the given pattern.static Patterns.PatternMatcherregex()Returns a PatternMatcher configured to use regex patterns explicitly.
-
Method Details
-
regex
Returns a PatternMatcher configured to use regex patterns explicitly.- Returns:
- a regex pattern matcher
-
glob
Returns a PatternMatcher configured to use glob patterns explicitly.- Returns:
- a glob pattern matcher
-
auto
Returns a PatternMatcher configured to auto-detect pattern type. This is the default behavior and equivalent to using the static methods directly.- Returns:
- an auto-detecting pattern matcher
-
match
-
match
-
isIncluded
-
isExcluded
-
matchesPattern
Checks if the target string matches the given pattern. Automatically detects whether the pattern is a glob or regex pattern.- Parameters:
target- the string to match againstpattern- the pattern (glob or regex)- Returns:
- true if the target matches the pattern
-
isGlobPattern
Determines if a pattern is a glob pattern or a regex pattern. Uses heuristics to detect common glob patterns vs regex patterns.- Parameters:
pattern- the pattern to analyze- Returns:
- true if the pattern appears to be a glob pattern, false for regex
-
matchesGlob
Matches a target string against a glob pattern. Supports wildcards: * (any characters), ? (single character), ** (directory traversal).- Parameters:
target- the string to matchglob- the glob pattern- Returns:
- true if the target matches the glob pattern
-
globToRegex
Converts a glob pattern to a regular expression. Handles directory traversal (**), wildcards (*), and single character matches (?).- Parameters:
glob- the glob pattern- Returns:
- the equivalent regular expression
-