
org.zalando.logbook.Glob Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of logbook-core Show documentation
Show all versions of logbook-core Show documentation
HTTP request and response logging
package org.zalando.logbook;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Predicate;
import java.util.regex.Pattern;
final class Glob {
private static final Pattern GLOB = Pattern.compile("\\?|(/\\*{2}$)|\\*{2}|(/\\*$)|\\*");
private static final Map REPLACEMENTS;
static {
final Map replacements = new HashMap<>();
replacements.put("?", ".");
replacements.put("/**", "(/.*)?$");
replacements.put("**", ".*?");
replacements.put("/*", "/[^/]*$");
REPLACEMENTS = Collections.unmodifiableMap(replacements);
}
public static Predicate compile(final String glob) {
return PatternLike.compile(GLOB, glob, Glob::translate);
}
private static String translate(final String match) {
return REPLACEMENTS.getOrDefault(match, "[^/]*?");
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy