diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 09cd2bd9..fee614a2 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,20 +1,23 @@ # Contributing -Contributions are very welcome. The following will provide some helpful guidelines. +Contributions are very welcome! ## How to contribute We love pull requests. Here is a quick guide: -2. Fork the repo. -3. Create a new branch from master. -5. Add your change together with necessary tests. -6. Run `mvn clean build` and ensure all tests are passing. -7. Commit and push to your fork/branch and submit a pull request. Don't forget to sign-off your commit (see next section). -8. Create a pull request. +1. Fork the repo. +2. Create a new branch from `master`. +3. Add your change together with necessary tests. +4. Run `mvn clean build` and ensure all tests are passing. +5. Commit with a DCO sign-off message (see next section) and push to your fork/branch. +6. Create a pull request. -## Sign your work - the Developer's Certificate of Origin -The sign-off is a simple line at the end of the explanation for the patch, which certifies that you wrote it or otherwise have the right to pass it on as an open-source patch. The rules are pretty simple: if you can certify the below (from developercertificate.org): +## Sign your work – the Developer's Certificate of Origin +The sign-off is a simple line at the end of the explanation for the patch, +which certifies that you wrote it or otherwise have the right to pass it on as an open-source patch. +The rules are pretty simple: +You need to certify the below (from [developercertificate.org](https://developercertificate.org/)): > Developer's Certificate of Origin 1.1 > @@ -46,11 +49,16 @@ The sign-off is a simple line at the end of the explanation for the patch, which The DCO requires a sign-off message in the following format appear on each commit in the pull request: -> Signed-off-by: Random J Developer + Signed-off-by: Random J Developer using your real name (sorry, no pseudonyms or anonymous contributions.) -The DCO text can either be manually added to your commit body, or you can add either **-s** or **--signoff** to your usual git commit commands. If you forget to add the sign-off you can also amend a previous commit with the sign-off by running **git commit --amend -s**. If you've pushed your changes to Github already you'll need to force push your branch after this with **git push -f**. +The DCO text can either be manually added to your commit body, +or you can add either **`-s`** or **`--signoff`** to your usual **`git commit`** commands. +If you forget to add the sign-off you can also amend a previous commit with the sign-off +by running **`git commit --amend -s`**. +If you've pushed your changes to Github already +you'll need to force push your branch after this with **`git push -f`**. #### Alternative Sign-Off Methods in rare cases diff --git a/pom.xml b/pom.xml index 978d3421..a44417da 100644 --- a/pom.xml +++ b/pom.xml @@ -183,13 +183,13 @@ org.mockito mockito-core - 2.19.0 + 2.28.2 test org.assertj assertj-core - 3.10.0 + 3.12.2 test diff --git a/src/main/java/com/tngtech/configbuilder/ConfigBuilder.java b/src/main/java/com/tngtech/configbuilder/ConfigBuilder.java index 3aac859f..fe79902b 100644 --- a/src/main/java/com/tngtech/configbuilder/ConfigBuilder.java +++ b/src/main/java/com/tngtech/configbuilder/ConfigBuilder.java @@ -66,9 +66,7 @@ public class ConfigBuilder { private Properties additionalProperties; private String[] commandLineArgs = {}; - protected ConfigBuilder(Class configClass, ConfigBuilderFactory configBuilderFactory) { - configBuilderFactory.initialize(); this.configClass = configClass; this.builderConfiguration = configBuilderFactory.getInstance(BuilderConfiguration.class); @@ -104,7 +102,7 @@ public ConfigBuilder withCommandLineArgs(String[] args) { /** * Imports the values from the given object according to the field names in the annotations - * @param importedConfiguration + * @param importedConfiguration configuration object to be imported * @return the instance of ConfigBuilder */ public ConfigBuilder withImportedConfiguration(Object importedConfiguration) { @@ -113,9 +111,9 @@ public ConfigBuilder withImportedConfiguration(Object importedConfiguration) } /** - * Configures the Config Builder to load given properties files instead of those specified in the config class. + * Configures the Config Builder to load given property files instead of those specified in the config class. * - * @param baseNames + * @param baseNames base names of the property files to be loaded * @return the instance of ConfigBuilder */ public ConfigBuilder overridePropertiesFiles(List baseNames) { @@ -291,6 +289,7 @@ private void initializeErrorMessageSetup(PropertyLoader propertyLoader) { * Gets an instance of the ConfigBuilder for a given config class * * @param clazz config class for which the config builder is instantiated. + * @param generic type of the config class * @return ConfigBuilder instance for config class */ public static ConfigBuilder on(Class clazz) { diff --git a/src/main/java/com/tngtech/configbuilder/annotation/valueextractor/CommandLineValueProcessor.java b/src/main/java/com/tngtech/configbuilder/annotation/valueextractor/CommandLineValueProcessor.java index 6e0a4295..c5e03cf0 100644 --- a/src/main/java/com/tngtech/configbuilder/annotation/valueextractor/CommandLineValueProcessor.java +++ b/src/main/java/com/tngtech/configbuilder/annotation/valueextractor/CommandLineValueProcessor.java @@ -7,7 +7,7 @@ import java.lang.annotation.Annotation; /** - * Processes CommandLineValue annotations, implements ValueExtractorProcessor + * Processes {@link CommandLineValue} annotations */ public class CommandLineValueProcessor implements ValueExtractorProcessor { diff --git a/src/main/java/com/tngtech/configbuilder/annotation/valueextractor/DefaultValueProcessor.java b/src/main/java/com/tngtech/configbuilder/annotation/valueextractor/DefaultValueProcessor.java index 3b5471a7..69fd9dc5 100644 --- a/src/main/java/com/tngtech/configbuilder/annotation/valueextractor/DefaultValueProcessor.java +++ b/src/main/java/com/tngtech/configbuilder/annotation/valueextractor/DefaultValueProcessor.java @@ -5,7 +5,7 @@ import java.lang.annotation.Annotation; /** - * Processes DefaultValue annotations, implements ValueExtractorProcessor + * Processes {@link DefaultValue} annotations */ public class DefaultValueProcessor implements ValueExtractorProcessor { diff --git a/src/main/java/com/tngtech/configbuilder/annotation/valueextractor/EnvironmentVariableProcessor.java b/src/main/java/com/tngtech/configbuilder/annotation/valueextractor/EnvironmentVariableProcessor.java index e739128b..ebc2931d 100644 --- a/src/main/java/com/tngtech/configbuilder/annotation/valueextractor/EnvironmentVariableProcessor.java +++ b/src/main/java/com/tngtech/configbuilder/annotation/valueextractor/EnvironmentVariableProcessor.java @@ -5,7 +5,7 @@ import java.lang.annotation.Annotation; /** - * Processes EnvironmentVariableValue annotations, implements ValueExtractorProcessor + * Processes {@link EnvironmentVariableValue} annotations */ public class EnvironmentVariableProcessor implements ValueExtractorProcessor { public String getValue(Annotation annotation, ConfigBuilderFactory configBuilderFactory) { diff --git a/src/main/java/com/tngtech/configbuilder/annotation/valueextractor/PropertyValueProcessor.java b/src/main/java/com/tngtech/configbuilder/annotation/valueextractor/PropertyValueProcessor.java index 4dcf0d39..ce17ff86 100644 --- a/src/main/java/com/tngtech/configbuilder/annotation/valueextractor/PropertyValueProcessor.java +++ b/src/main/java/com/tngtech/configbuilder/annotation/valueextractor/PropertyValueProcessor.java @@ -7,7 +7,7 @@ import java.util.Properties; /** - * Processes PropertyValue annotations, implements ValueExtractorProcessor + * Processes {@link PropertyValue} annotations */ public class PropertyValueProcessor implements ValueExtractorProcessor { diff --git a/src/main/java/com/tngtech/configbuilder/annotation/valueextractor/SystemPropertyProcessor.java b/src/main/java/com/tngtech/configbuilder/annotation/valueextractor/SystemPropertyProcessor.java index 55aae77d..4f16ff7b 100644 --- a/src/main/java/com/tngtech/configbuilder/annotation/valueextractor/SystemPropertyProcessor.java +++ b/src/main/java/com/tngtech/configbuilder/annotation/valueextractor/SystemPropertyProcessor.java @@ -5,7 +5,7 @@ import java.lang.annotation.Annotation; /** - * Processes SystemPropertyValue annotations, implements ValueExtractorProcessor + * Processes {@link SystemPropertyValue} annotations */ public class SystemPropertyProcessor implements ValueExtractorProcessor { public String getValue(Annotation annotation, ConfigBuilderFactory configBuilderFactory) { diff --git a/src/main/java/com/tngtech/configbuilder/annotation/valueextractor/SystemPropertyValue.java b/src/main/java/com/tngtech/configbuilder/annotation/valueextractor/SystemPropertyValue.java index 7a7ba624..edde492a 100644 --- a/src/main/java/com/tngtech/configbuilder/annotation/valueextractor/SystemPropertyValue.java +++ b/src/main/java/com/tngtech/configbuilder/annotation/valueextractor/SystemPropertyValue.java @@ -7,7 +7,7 @@ /** * This annotation is used to specify system properties.
- * Usage: @EnvironmentVariableValue("property.key") + * Usage: @SystemPropertyValue("property.key") */ @ValueExtractorAnnotation(SystemPropertyProcessor.class) @Target(ElementType.FIELD) diff --git a/src/main/java/com/tngtech/configbuilder/configuration/BuilderConfiguration.java b/src/main/java/com/tngtech/configbuilder/configuration/BuilderConfiguration.java index bb33a34b..07f182a2 100644 --- a/src/main/java/com/tngtech/configbuilder/configuration/BuilderConfiguration.java +++ b/src/main/java/com/tngtech/configbuilder/configuration/BuilderConfiguration.java @@ -11,18 +11,12 @@ */ public class BuilderConfiguration { - private Properties properties; - private CommandLine commandLine; - private Object importedConfiguration; + private Properties properties = new Properties(); + private CommandLine commandLine = null; + private Object importedConfiguration = null; private Class[] annotationOrder = new Class[]{CommandLineValue.class, PropertyValue.class, EnvironmentVariableValue.class, SystemPropertyValue.class, ImportedValue.class, DefaultValue.class}; private String[] propertyNamePrefixes = new String[]{""}; - public BuilderConfiguration() { - properties = new Properties(); - commandLine = null; - importedConfiguration = null; - } - public CommandLine getCommandLine() { return commandLine; }