mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-05-21 04:01:27 +00:00
Apply code suggestion from review
Co-authored-by: Sebastian Stenzel <overheadhunter@users.noreply.github.com>
This commit is contained in:
@@ -9,7 +9,7 @@ import java.util.regex.Pattern;
|
||||
public class PropertiesPreprocessor {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(PropertiesPreprocessor.class);
|
||||
private static final Pattern TEMPLATE = Pattern.compile("@\\((.+)\\)");
|
||||
private static final Pattern TEMPLATE = Pattern.compile("@\\{(\\w+)}");
|
||||
private static final LoggingEnvironment ENV = new LoggingEnvironment(System.getenv(), LOG);
|
||||
|
||||
public static void run() {
|
||||
@@ -29,12 +29,12 @@ public class PropertiesPreprocessor {
|
||||
|
||||
private static String process(String value) {
|
||||
return TEMPLATE.matcher(value).replaceAll(match -> //
|
||||
switch (match.group().substring(2, match.group().length() - 1)) {
|
||||
switch (match.group(1)) {
|
||||
case "appdir" -> ENV.get("APPDIR");
|
||||
case "appdata" -> ENV.get("APPDATA");
|
||||
case "userhome" -> System.getProperty("user.home");
|
||||
default -> {
|
||||
LOG.warn("Found unknown keyword {} in property value {}. Keyword is not replaced.", match.group(), value);
|
||||
LOG.warn("Found unknown variable @{{}} in property value {}.", match.group(), value);
|
||||
yield match.group();
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user