diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..343066c
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,62 @@
+root = true
+
+[*]
+charset = utf-8
+end_of_line = lf
+insert_final_newline = true
+trim_trailing_whitespace = true
+
+########################################
+# Java
+########################################
+[*.java]
+indent_style = space
+indent_size = 4
+max_line_length = off
+
+########################################
+# XML (POM files, Spring XML, misc)
+########################################
+[*.xml]
+indent_style = space
+indent_size = 2
+
+########################################
+# JSON
+########################################
+[*.json]
+indent_style = space
+indent_size = 2
+
+########################################
+# YAML (docker-compose, GitHub actions, configs)
+# YAML SHOULD NEVER USE TABS — many parsers reject them
+########################################
+[*.{yml,yaml}]
+indent_style = space
+indent_size = 2
+
+
+########################################
+# Markdown
+# Keep indentation small; used mainly for lists and fenced blocks.
+########################################
+[*.md]
+indent_style = space
+indent_size = 2
+trim_trailing_whitespace = false # needed to preserve Markdown hard line breaks
+
+########################################
+# Properties files
+# Key-value pairs; indenting rarely matters but 2 spaces is common.
+########################################
+[*.properties]
+indent_style = space
+indent_size = 2
+
+########################################
+# HTML (simple default)
+########################################
+[*.html]
+indent_style = space
+indent_size = 2
diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs
new file mode 100644
index 0000000..30eb6ad
--- /dev/null
+++ b/.git-blame-ignore-revs
@@ -0,0 +1 @@
+eb7e29d5e4b012e89f277e7d275381bb1624669f
diff --git a/README.md b/README.md
index 4336642..e4db758 100644
--- a/README.md
+++ b/README.md
@@ -1,3 +1,21 @@
# exense-commons
-This project contains functionality reused across a variety of applications built internally at exense GmbH and is open for external collaboration purposes.
+This project contains functionality reused across a variety of applications built internally at exense GmbH and is open
+for external collaboration purposes.
+
+## Instructions for developers
+
+### Code formatting (indentation and line breaks)
+
+Use an IDE that supports the `.editorconfig` standard and make sure that it is enabled. This will automatically
+apply the recommended settings to all files.
+
+### Git blame history
+
+To ensure correct handling of "reformat-only" commits, use a recent git version (>= 2.23) with the following
+configuration. You can do this per-repository (in that case, omit the `--global` flag), but the filename used
+is a de-facto standard, and this way you'll only need to do this once, not for every repository:
+
+```
+git config --global blame.ignoreRevsFile .git-blame-ignore-revs
+```
diff --git a/build_parameters.json b/build_parameters.json
index 5bf2987..05de9c7 100644
--- a/build_parameters.json
+++ b/build_parameters.json
@@ -1,17 +1,17 @@
{
- "ACTION": "COMPILE",
- "TYPE": "POM",
- "FOLDER": ".",
- "PARAMETERS": [
- {
- "NAME": "DEVELOPMENT",
- "URL": "nexus-staging::https://nexus-enterprise-staging.exense.ch/repository/staging-maven/",
- "CONFIG": "SkipJavadoc"
- },
- {
- "NAME": "PRODUCTION",
- "URL": "sonatype::https://ossrh-staging-api.central.sonatype.com/service/local/staging/deploy/maven2/",
- "CONFIG": "SignedBuild"
- }
- ]
-}
\ No newline at end of file
+ "ACTION": "COMPILE",
+ "TYPE": "POM",
+ "FOLDER": ".",
+ "PARAMETERS": [
+ {
+ "NAME": "DEVELOPMENT",
+ "URL": "nexus-staging::https://nexus-enterprise-staging.exense.ch/repository/staging-maven/",
+ "CONFIG": "SkipJavadoc"
+ },
+ {
+ "NAME": "PRODUCTION",
+ "URL": "sonatype::https://ossrh-staging-api.central.sonatype.com/service/local/staging/deploy/maven2/",
+ "CONFIG": "SignedBuild"
+ }
+ ]
+}
diff --git a/exense-basic-commons/pom.xml b/exense-basic-commons/pom.xml
index a458a96..9eff3ca 100644
--- a/exense-basic-commons/pom.xml
+++ b/exense-basic-commons/pom.xml
@@ -1,45 +1,45 @@
- 4.0.0
-
- exense-basic-commons
- jar
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ 4.0.0
- ${project.groupId}:${project.artifactId}
-
-
- ch.exense.commons
- exense-commons
- 0.0.0-SNAPSHOT
-
-
-
-
- org.slf4j
- slf4j-api
-
+ exense-basic-commons
+ jar
-
- ch.qos.logback
- logback-classic
- test
-
-
+ ${project.groupId}:${project.artifactId}
-
-
-
- org.apache.maven.plugins
- maven-jar-plugin
-
-
-
- test-jar
-
-
-
-
-
-
+
+ ch.exense.commons
+ exense-commons
+ 0.0.0-SNAPSHOT
+
+
+
+
+ org.slf4j
+ slf4j-api
+
+
+
+ ch.qos.logback
+ logback-classic
+ test
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-jar-plugin
+
+
+
+ test-jar
+
+
+
+
+
+
diff --git a/exense-basic-commons/src/main/java/ch/exense/commons/app/ArgumentParser.java b/exense-basic-commons/src/main/java/ch/exense/commons/app/ArgumentParser.java
index 6d460bc..5fbaf29 100644
--- a/exense-basic-commons/src/main/java/ch/exense/commons/app/ArgumentParser.java
+++ b/exense-basic-commons/src/main/java/ch/exense/commons/app/ArgumentParser.java
@@ -1,12 +1,12 @@
/*******************************************************************************
* Copyright 2021 exense GmbH
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy
* of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -24,31 +24,31 @@
public class ArgumentParser {
- private HashMap options = new HashMap();
- private Pattern p = Pattern.compile("-(.+?)(?:=(.+?))?$");
-
- public ArgumentParser(String[] paramArrayOfString) {
- Matcher localMatcher = null;
- for (int i = 0; i < paramArrayOfString.length; i++) {
- if (!(localMatcher = this.p.matcher(paramArrayOfString[i])).find())
- continue;
- this.options.put(localMatcher.group(1).toLowerCase(), localMatcher.group(2));
- }
- }
-
- public boolean hasOption(String paramString) {
- return this.options.containsKey(paramString.toLowerCase());
- }
-
- public String getOption(String paramString) {
- return (String) this.options.get(paramString.toLowerCase());
- }
-
- public Set> entrySet() {
- return options.entrySet();
- }
-
- public Map getOptions() {
- return options;
- }
+ private HashMap options = new HashMap();
+ private Pattern p = Pattern.compile("-(.+?)(?:=(.+?))?$");
+
+ public ArgumentParser(String[] paramArrayOfString) {
+ Matcher localMatcher = null;
+ for (int i = 0; i < paramArrayOfString.length; i++) {
+ if (!(localMatcher = this.p.matcher(paramArrayOfString[i])).find())
+ continue;
+ this.options.put(localMatcher.group(1).toLowerCase(), localMatcher.group(2));
+ }
+ }
+
+ public boolean hasOption(String paramString) {
+ return this.options.containsKey(paramString.toLowerCase());
+ }
+
+ public String getOption(String paramString) {
+ return (String) this.options.get(paramString.toLowerCase());
+ }
+
+ public Set> entrySet() {
+ return options.entrySet();
+ }
+
+ public Map getOptions() {
+ return options;
+ }
}
diff --git a/exense-basic-commons/src/main/java/ch/exense/commons/app/Configuration.java b/exense-basic-commons/src/main/java/ch/exense/commons/app/Configuration.java
index c94c715..5443c14 100644
--- a/exense-basic-commons/src/main/java/ch/exense/commons/app/Configuration.java
+++ b/exense-basic-commons/src/main/java/ch/exense/commons/app/Configuration.java
@@ -1,12 +1,12 @@
/*******************************************************************************
* Copyright 2021 exense GmbH
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy
* of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -35,187 +35,187 @@
public class Configuration implements Closeable {
- private static final Logger logger = LoggerFactory.getLogger(Configuration.class);
-
- private FileWatchService fileWatchService;
-
- private File propertyFile;
-
- private Properties properties;
-
- private Map placeholders;
-
- public Configuration() {
- super();
- properties = new Properties();
- }
-
- public Configuration(File propertyFile) throws IOException {
- this(propertyFile, new HashMap<>());
- }
-
- public Configuration(File propertyFile, Map placeholders) throws IOException {
- super();
-
- this.propertyFile = propertyFile;
- this.placeholders = placeholders;
-
- load();
-
- if (getPropertyAsBoolean("conf.scan", false)) {
- fileWatchService = new FileWatchService();
- fileWatchService.register(propertyFile, new Runnable() {
- @Override
- public void run() {
- try {
- load();
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
- });
- }
- }
-
- public void load() throws FileNotFoundException, IOException {
- properties = new Properties();
- if (propertyFile != null) {
- String propertiesContent = new String(Files.readAllBytes(propertyFile.toPath()));
- String resolvedPropertiesContent = replacePlaceholders(propertiesContent);
- properties.load(new StringReader(resolvedPropertiesContent));
- }
- }
-
- private String replacePlaceholders(String configXml) {
- StringBuffer sb = new StringBuffer();
- Matcher m = Pattern.compile("\\$\\{(.+?)\\}").matcher(configXml);
- while (m.find()) {
+ private static final Logger logger = LoggerFactory.getLogger(Configuration.class);
+
+ private FileWatchService fileWatchService;
+
+ private File propertyFile;
+
+ private Properties properties;
+
+ private Map placeholders;
+
+ public Configuration() {
+ super();
+ properties = new Properties();
+ }
+
+ public Configuration(File propertyFile) throws IOException {
+ this(propertyFile, new HashMap<>());
+ }
+
+ public Configuration(File propertyFile, Map placeholders) throws IOException {
+ super();
+
+ this.propertyFile = propertyFile;
+ this.placeholders = placeholders;
+
+ load();
+
+ if (getPropertyAsBoolean("conf.scan", false)) {
+ fileWatchService = new FileWatchService();
+ fileWatchService.register(propertyFile, new Runnable() {
+ @Override
+ public void run() {
+ try {
+ load();
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+ });
+ }
+ }
+
+ public void load() throws FileNotFoundException, IOException {
+ properties = new Properties();
+ if (propertyFile != null) {
+ String propertiesContent = new String(Files.readAllBytes(propertyFile.toPath()));
+ String resolvedPropertiesContent = replacePlaceholders(propertiesContent);
+ properties.load(new StringReader(resolvedPropertiesContent));
+ }
+ }
+
+ private String replacePlaceholders(String configXml) {
+ StringBuffer sb = new StringBuffer();
+ Matcher m = Pattern.compile("\\$\\{(.+?)\\}").matcher(configXml);
+ while (m.find()) {
String key = m.group(1);
- if(placeholders!=null) {
- String replacement = placeholders.get(key.toLowerCase());
- if(replacement == null) {
- throw new RuntimeException("Missing placeholder '"+key+"'.");
- } else {
- m.appendReplacement(sb, Matcher.quoteReplacement(replacement));
- }
+ if (placeholders != null) {
+ String replacement = placeholders.get(key.toLowerCase());
+ if (replacement == null) {
+ throw new RuntimeException("Missing placeholder '" + key + "'.");
+ } else {
+ m.appendReplacement(sb, Matcher.quoteReplacement(replacement));
+ }
} else {
- throw new RuntimeException("Unable to replace placeholders. Placeholder map is null. This should never occur.");
+ throw new RuntimeException("Unable to replace placeholders. Placeholder map is null. This should never occur.");
}
}
- m.appendTail(sb);
- return sb.toString();
- }
-
- public Properties getUnderlyingPropertyObject(){
- return this.properties;
- }
-
- public String getProperty(String name) {
- return properties.getProperty(name);
- }
-
- public String getProperty(String name, String defaultValue) {
- return properties.getProperty(name, defaultValue);
- }
-
- public void putProperty(String name, String value) {
- properties.put(name, value);
- }
-
- public Integer getPropertyAsInteger(String name) {
- return getPropertyAsInteger(name, null);
- }
-
- public Integer getPropertyAsInteger(String name, Integer defaultValue) {
- String prop = properties.getProperty(name);
- if (prop != null) {
- return Integer.parseInt(prop);
- } else {
- return defaultValue;
- }
- }
-
- public Long getPropertyAsLong(String name) {
- return getPropertyAsLong(name, null);
- }
-
- public Long getPropertyAsLong(String name, Long defaultValue) {
- String prop = properties.getProperty(name);
- if (prop != null) {
- return Long.parseLong(prop);
- } else {
- return defaultValue;
- }
- }
-
- public boolean getPropertyAsBoolean(String name) {
- return getPropertyAsBoolean(name, false);
- }
-
- public boolean hasProperty(String name) {
- return properties.containsKey(name);
- }
-
- public boolean getPropertyAsBoolean(String name, boolean defaultValue) {
- String prop = properties.getProperty(name);
- if (prop != null) {
- return Boolean.parseBoolean(prop);
- } else {
- return defaultValue;
- }
- }
-
- public File getPropertyAsFile(String name) {
- return getPropertyAsFile(name, null);
- }
-
- public File getPropertyAsFile(String name, File defaultValue) {
- String prop = properties.getProperty(name);
- if (prop != null) {
- return new File(prop);
- } else {
- return defaultValue;
- }
- }
-
- public File getPropertyAsDirectory(String name) {
- return getPropertyAsFile(name, null);
- }
-
- public File getPropertyAsDirectory(String name, File defaultValue) {
- String prop = properties.getProperty(name);
- File file;
- if (prop != null) {
- file = new File(prop);
- } else {
- file = defaultValue;
- }
- if(!file.exists()) {
- file.mkdirs();
- }
- return file;
- }
-
- public File getPropertyFile() {
- return propertyFile;
- }
-
- /**
- * @return the {@link Set} of property names (keys) contained in this {@link Configuration}
- */
- public Set