Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
93 commits
Select commit Hold shift + click to select a range
7e15972
additional unit tests for LngValidator
chace86 Oct 14, 2018
1bc3a77
Small changes to TextUtil logic (findFirst and LastInstanceOf) and in…
shouxian92 Oct 14, 2018
30b7045
Extra docs to clarify functionality and additional unit tests to achi…
shouxian92 Oct 15, 2018
38d8e02
Unit tests for AppFatalException class
Oct 15, 2018
4692ce3
Added missing asserting
Oct 16, 2018
6a2a9cb
Added initial detection of reentrant initiation - WIP
ee-usgs Oct 13, 2018
27d7722
WIP
ee-usgs Oct 13, 2018
2466f91
* Added a initializing flag to block reentrant initialization
ee-usgs Oct 16, 2018
02fc996
Added a test for a new constructor
ee-usgs Oct 16, 2018
56e8d54
Updated readme file w/ better explanations and added main(String[] args)
ee-usgs Oct 17, 2018
50dbdce
Added forgotten import
ee-usgs Oct 17, 2018
f64409b
Add some javadoc to IOUtil.java to fix issue andhow#416
yirrilo Oct 20, 2018
7e6d382
Modification to manage code review comments on the javadoc
yirrilo Oct 20, 2018
5a68e4e
RM extra javadoc line that ended up in the code.
ee-usgs Oct 21, 2018
c8ca865
Construction problem unit tests (#415)
jr7square Oct 22, 2018
29f0d84
Fixes #437 (#440)
arrodriguez Oct 23, 2018
0966301
Added logo contest to the Readme
eeverman Oct 27, 2018
febd9f4
Adding javadoc linting options to ignore warnings
code4t2 Oct 27, 2018
84597de
Update StringValidator.java
winsonrich Oct 20, 2018
fb76e1f
Update LngValidator.java
winsonrich Oct 20, 2018
9c4953a
Update IntValidator.java
winsonrich Oct 20, 2018
3a47d5d
Update DblValidator.java
winsonrich Oct 20, 2018
09bebf7
Fixing the last javadoc warning.
code4t2 Oct 28, 2018
5ed56c1
Remove duplicate and misnamed clearJNDIBeforeTest method.
ufko Oct 30, 2018
c5bbffa
Steps towards removing the static get method
code4t2 Nov 1, 2018
ca298de
add intellij iml files to gitignore
chace86 Oct 22, 2018
ea95de9
Big Decimal type and tests
chace86 Oct 22, 2018
1a477d0
BigDecimal validator and tests
chace86 Oct 24, 2018
4155197
add BigDecimal property and tests
chace86 Oct 29, 2018
1250c24
replace values with constants
chace86 Oct 29, 2018
38afd72
add javadocs to property builder methods
chace86 Oct 29, 2018
b2285fd
add javadocs to BigDec prop, validator, type
chace86 Oct 31, 2018
ca1ed81
add jndi and system prop tests to BigDec
chace86 Oct 31, 2018
ed489ac
simplify test to assertNotNull
chace86 Oct 31, 2018
5ce4514
validator javadocs, abstract common logic with subclasses, rework spe…
chace86 Nov 1, 2018
7ebe7ee
expand javadoc on how source is parsed in BigDecType
chace86 Nov 1, 2018
80f42df
add return to BigDec prop javadocs
chace86 Nov 1, 2018
0b050c7
add SciNotation numbers; rename test constants for readability
chace86 Nov 1, 2018
2d3dc84
add validator must description tests to validator tests
chace86 Nov 1, 2018
64c799c
change validator invalid specification message; change validator tests
chace86 Nov 3, 2018
acfb009
WIP: Initial testing
ee-usgs Oct 19, 2018
a66ecf0
WIP: new exception and problem type
ee-usgs Oct 21, 2018
429775a
Improved reporting of compile time errors
ee-usgs Oct 23, 2018
01d2c86
Completely removed the SimpleVariable class - easily factored out
ee-usgs Oct 24, 2018
3156424
Removed TooManyInitClassesException and replaced it with a CompilePro…
ee-usgs Oct 25, 2018
37da16f
Improved test coverage and made some fields private
ee-usgs Oct 25, 2018
4222eab
Improved testability and testing for AndHowCompileException
ee-usgs Oct 26, 2018
e63e4ed
Simplified the test
ee-usgs Oct 26, 2018
24231e6
* Added and simplified tests
ee-usgs Oct 26, 2018
c2db61d
Implemented Chace’s suggestion
ee-usgs Nov 2, 2018
cf4e68e
Update codecov.yml
eeverman Nov 22, 2018
6ba6a5d
Inital commit for MustMatch validation
rupeshA Oct 29, 2018
be63726
Update StrProp.java
eeverman Nov 22, 2018
7e4fa9b
Update StringValidator.java
eeverman Nov 22, 2018
21c8218
Update StringValidator.java
eeverman Nov 22, 2018
d58d7c6
Update StringValidator.java
eeverman Nov 22, 2018
fa35b8a
Issue469 compiler warnings (#472)
eeverman Dec 5, 2018
6531e66
Updated per new logo (#474)
eeverman Dec 10, 2018
8ff57a7
Logo winner (#475)
eeverman Dec 10, 2018
55f7701
Bump junit from 4.12 to 4.13.1
dependabot[bot] Oct 13, 2020
3a3bf2f
Bump commons-io from 2.6 to 2.7 (#480)
dependabot[bot] Apr 29, 2021
1cbc9dc
Merge branch 'dependabot/maven/junit-junit-4.13.1' of https://github.…
ee-usgs Apr 29, 2021
61c4649
Bump junit from 4.12 to 4.13.1 (#479)
dependabot[bot] Apr 29, 2021
35c18ac
Issue481 travis build fails (#482)
eeverman Apr 29, 2021
aa3603c
Merge branch 'master' of https://github.com/eeverman/andhow
ee-usgs Apr 29, 2021
e40a5ea
Possible fix (#483)
eeverman Apr 29, 2021
4e6721c
Possible fix (#486)
eeverman May 21, 2021
7fe695f
Changed the distro for the build - rumored to fix this issue. (#487)
eeverman May 21, 2021
b43e5c1
Fix Issue 484 and 485 (#488)
eeverman May 21, 2021
ff49eb6
took out unwrap code so it can be added by the author (#489)
eeverman May 26, 2021
fc3252e
AnnotationProcessor now reports it supports all JDK versions (#493)
eeverman Jun 1, 2021
f3a5a93
Now using the Generated annotation on generated files (#494)
eeverman Jun 2, 2021
f12cc45
Added conditional unwrapping of ProcessingEnvironment when running bu…
VickyRonnen Jun 2, 2021
f1fb37a
Added sonatype's staging plugin to (hopefully) make releases easier (…
eeverman Jun 3, 2021
51950c3
[maven-release-plugin] prepare release andhow-0.4.1
ee-usgs Jun 3, 2021
2254506
[maven-release-plugin] prepare for next development iteration
ee-usgs Jun 3, 2021
12e31b1
[maven-release-plugin] rollback the release of andhow-0.4.1
ee-usgs Jun 3, 2021
d228c44
Minor javadoc fix to allow a release
ee-usgs Jun 3, 2021
943f6d2
[maven-release-plugin] prepare release andhow-0.4.1
ee-usgs Jun 3, 2021
dedd2bd
Revert "[maven-release-plugin] prepare release andhow-0.4.1"
ee-usgs Jun 3, 2021
64589c6
[maven-release-plugin] prepare release andhow-0.4.1
ee-usgs Jun 3, 2021
81f453e
[maven-release-plugin] prepare for next development iteration
ee-usgs Jun 3, 2021
786b87e
Readme update per 0.4.1 release
ee-usgs Jun 3, 2021
c249517
Readme formatting
ee-usgs Jun 3, 2021
92c5897
readme formatting
ee-usgs Jun 3, 2021
870a90f
Update README.md
eeverman Jun 8, 2021
26cd1d1
Update README.md
eeverman Jun 9, 2021
d8aaffe
Issue501 update junit (#502)
eeverman Jun 17, 2021
84143c1
Update README.md
eeverman Jun 18, 2021
b33fbb5
Exclude annotation-processor-test-harness from the codecov report (#504)
eeverman Jun 18, 2021
0431761
WIP: Issue 282 std config should accept fix value names as strings (#…
eeverman Jul 9, 2021
d815e6c
Testing improvements for StdConfig (#511)
eeverman Jul 11, 2021
63404e7
Fixes Issue #512 to improve config and testing UX (#513)
eeverman Jul 20, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ release.properties

#IntelliJ Project directory
.idea/
**.iml
.java-version
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
dist: trusty
language: java
jdk:
- oraclejdk8
- openjdk8
branches:
except:
- logo_submission

script: "mvn cobertura:cobertura"

Expand Down
123 changes: 77 additions & 46 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
[![Build Status](https://travis-ci.org/eeverman/andhow.svg?branch=master)](https://travis-ci.org/eeverman/andhow)
[![Build Status](https://travis-ci.com/eeverman/andhow.svg?branch=master)](https://travis-ci.com/github/eeverman/andhow)
[![codecov](https://codecov.io/gh/eeverman/andhow/branch/master/graph/badge.svg)](https://codecov.io/gh/eeverman/andhow)
[![Javadocs](https://www.javadoc.io/badge/org.yarnandtail/andhow.svg)](https://www.javadoc.io/doc/org.yarnandtail/andhow)


## New Release: 0.4.1, June 2, 2021 ([notes](https://github.com/eeverman/andhow/releases/tag/andhow-0.4.1)).
<img src="https://github.com/eeverman/andhow/raw/master/logo/AndHow-empty-circle-combination.png" width="55" height="72" alt="AndHow's new logo" align="left">

This larger update fixes several issues due to newer JVMs and the IntelliJ IDE.
Special thanks to first time contributor [Vicky Ronnen](https://github.com/VickyRonnen) for fixing Issue [497](https://github.com/eeverman/andhow/issues/497) -
This bug made AndHow unusable for anyone using newer versions of IntelliJ.


![Andhow Visual](andhow.gif)
AndHow! strong.valid.simple.AppConfiguration
======
## AndHow! strong.valid.simple.AppConfiguration
AndHow is an easy to use configuration framework with strong typing and detailed
validation for web apps, command line or any application environment.

_**Learn more at the [AndHow main site](https://sites.google.com/view/andhow)**_

Key Features
--------------
## Key Features
* **Strong Typing**
* **Detailed validation**
* **Simple to use**
Expand All @@ -19,101 +27,123 @@ Key Features
* **Loads values from multiple sources (JNDI, env vars, prop files, etc)**
* **Generates configuration sample file based on application properties**

Questions / Discussion / Contact
--------------
## Questions / Discussion / Contact
[Join the discussion](https://sites.google.com/view/andhow/join-discussion)
on the [user forum](https://groups.google.com/d/forum/andhowuser)
or the *Slack* group (See details on the
[Join](https://sites.google.com/view/andhow/join-discussion) page).

Use it via Maven (available on Maven Central)
--------------
## Use it via Maven (available on Maven Central)
```xml
<dependency>
<groupId>org.yarnandtail</groupId>
<artifactId>andhow</artifactId>
<version>0.4.0</version>
<version>0.4.1</version>
</dependency>
```
**AndHow can be used in projects with Java 8 and above, however, Java 9 and above have [some restrictions](https://sites.google.com/view/andhow/user-guide/java9)**
**AndHow can be used in projects with Java 8 - Java 15. Work to support Java 16 is underway and will be the next major release. There are [some considerations](https://sites.google.com/view/andhow/user-guide/java9-and-above) for Java 9 and above if your project uses Jigsaw Modules.**

Complete Usage Example
--------------
## Complete Usage Example
_**More usage examples and documentation
are available at the [AndHow main site](https://sites.google.com/view/andhow)**_
```java
package org.simple;

import org.yarnandtail.andhow.AndHow;
import org.yarnandtail.andhow.property.*;

public class GettingStarted {
//1
final static IntProp COUNT_DOWN_START = IntProp.builder().mustBeNonNull()
.desc("Start the countdown from this number")
.mustBeGreaterThanOrEqualTo(1).defaultValue(2).build();

public final static IntProp COUNT_DOWN_START = IntProp.builder().mustBeNonNull()
.mustBeGreaterThanOrEqualTo(1).defaultValue(3).build();

private final static StrProp LAUNCH_CMD = StrProp.builder().mustBeNonNull()
.desc("What to say when its time to launch")
.mustMatchRegex(".*Go.*").defaultValue("GoGoGo!").build();
.desc("What to say when its time to launch")
.mustMatchRegex(".*Go.*").defaultValue("Go-Go-Go!").build();
public String launch() {
String launch = "";
//2
for (int i = COUNT_DOWN_START.getValue(); i >= 1; i--) {
launch = launch += i + "...";
}
return launch + LAUNCH_CMD.getValue();
}

public static void main(String[] args) {
GettingStarted gs = new GettingStarted();
System.out.println(gs.launch());
AndHow.findConfig().setCmdLineArgs(args); //3 Optional

System.out.println( new GettingStarted().launch() );
System.out.println( LAUNCH_CMD.getValue().replace("Go", "Gone") );
}
}
```
### Section //1 : Declaring AndHow Properties
Properties must be `final static`, but may be `private` or any other scope.
`builder` methods simplify adding validation, description, defaults and
other metadata.
Properties are strongly typed, so default values and validation are specific to
the type, for instance, `StrProp` has regex validation rules for `String`s
while the `IntProp` has greater-than and less-than rules available.
Properties are strongly typed, so default values and validation are type specific, e.g.,
`StrProp` has Regex validation while the `IntProp` has GreaterThan / LessThan rules available.

### Section //2 : Using AndHow Properties
AndHow Properties are used just like static final constants with an added
`.getValue()` on the end to fetch the value.
Strong typing means that calling `COUNT_DOWN_START.getValue()`
`.getValue()` tacked on. Strong typing means that calling `COUNT_DOWN_START.getValue()`
returns an `Integer` while calling `LAUNCH_CMD.getValue()` returns a `String`.

An AndHow Property (and its value) can be accessed anywhere it is visible.
`COUNT_DOWN_START` is public in a public class, so it could be used anywhere, while
`LAUNCH_CMD` is private.
AndHow Properties are always `static`, so they can be accessed in both static
and instance methods, just like this example shows.

### Section //3 : Accepting Command Line Arguments
If an application needs command line arguments (CLAs), just pass them to AndHow
at startup as this example shows. Properties are referred to using 'dot notation', e.g.:
```
java -jar GettingStarted.jar org.simple.GettingStarted.LAUNCH_CMD=GoManGo
```
If you don't need to accept CLA's, you can leave line `//3` out -
AndHow will initialize and startup without any explicit _init_ method when
the first Property is accessed.

### How do I actually configure some values?
We're getting there.
The example has defaults for each property so with no other configuration available,
the main method uses the defaults and prints: `3...2...1...GoGoGo!`
Things are more interesting if the default values are removed from the code above.
the main method uses the defaults and prints:
```
3...2...1...Go-Go-Go!
Gone-Gone-Gone!
```
Things are more interesting if the default values are removed from the code above:
```java
public final static IntProp COUNT_DOWN_START = IntProp.builder().mustBeNonNull()
.mustBeGreaterThanOrEqualTo(1).build(); //default removed

private final static StrProp LAUNCH_CMD = StrProp.builder().mustBeNonNull()
.mustMatchRegex(".*Go.*").build(); //default removed
```
Both properties must be non-null, so removing the defaults causes the validation
rules to be violated at startup. Here is an excerpt of the console output when that happens:
rules to be violated at startup. Here is an excerpt from the console when that happens:
```
========================================================================
Drat! There were AndHow startup errors.
Sample configuration files will be written to: '/some_local_tmp_directory/andhow-samples/'
========================================================================
REQUIRMENT PROBLEMS - When a required property is not provided
Detailed list of Requirements Problems:
Property org.simple.GettingStarted.COUNT_DOWN_START: This Property must be non-null - It must have a non-null default or be loaded by one of the loaders to a non-null value
Property org.simple.GettingStarted.LAUNCH_CMD: This Property must be non-null - It must have a non-null default or be loaded by one of the loaders to a non-null value
Property org.simple.GettingStarted.COUNT_DOWN_START: This Property must be non-null
Property org.simple.GettingStarted.LAUNCH_CMD: This Property must be non-null
========================================================================
```

**Validation happens at startup and happens for all properties in the entire application.**
Properties, even those defined in 3rd party jars, are discovered and values for
**AndHow does validation at startup for all properties in the entire application.**
Properties, _even those defined in 3rd party jars_, are discovered and values for
them are loaded and validated.
If that fails (as it did above), AndHow throws a RuntimeException to stop
If validation fails (as it did above), AndHow throws a RuntimeException to stop
application startup and uses property metadata to generate specific error
messages and (helpfully) sample configuration files.
Here is an excerpt of the Java Properties file created when the example code failed validation:
Here is an excerpt of the Java Properties file created when the code above failed validation:
```
# ######################################################################
# Property Group org.simple.GettingStarted
Expand All @@ -129,15 +159,15 @@ org.simple.GettingStarted.LAUNCH_CMD = [String]
AndHow uses all of the provided metadata to create a detailed and well commented
configuration file for your project.
Insert some real values into that file and place it on your classpath at
/andhow.properties and it will automatically be discovered and loaded at startup.
By default, AndHow automatically discovers and loads configuration from seven common sources.
`/andhow.properties` and it will automatically be discovered and loaded at startup.
By default, AndHow discovers and loads configuration from seven common sources.
The default list of configuration loading, in order, is:
1. Fixed values (explicitly set in code for AndHow to use)
2. String[] arguments from the static void main() method
3. System Properties
3. System Properties _(Like the one auto-generated above)_
4. Environmental Variables
5. JNDI
6. Java properties file on the filesystem (path specified as an AndHow property)
6. Java properties file on the filesystem (path must be specified)
7. Java properties file on the classpath (defaults to /andhow.properties)

Property values are set on a first-win basis, so if a property is set as fixed value,
Expand All @@ -147,3 +177,4 @@ Values passed to the main method take precedence over system properties as so on
_**For more examples and documentation, visit the [AndHow main site](https://sites.google.com/view/andhow)**_

_**&?!**_

6 changes: 1 addition & 5 deletions andhow-annotation-processor/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>org.yarnandtail</groupId>
<artifactId>andhow-parent</artifactId>
<version>0.4.1-SNAPSHOT</version>
<version>0.4.2-SNAPSHOT</version>
</parent>

<artifactId>andhow-annotation-processor</artifactId>
Expand Down Expand Up @@ -38,10 +38,6 @@
</dependency>

<!-- All dependencies are test dependencies only -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
<dependency>
<groupId>com.google.testing.compile</groupId>
<artifactId>compile-testing</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package org.yarnandtail.andhow.compile;

import java.util.Collections;
import java.util.List;

/**
* Exception thrown by the AndHowCompileProcessor for any type of problem
* during the compile.
*
* This exception can accumulate a list of Problems so that all problems can
* be found in a single pass and for easier testing (this exception can be
* inspected to determine the exact problem).
*
* @author ericeverman
*/
public class AndHowCompileException extends RuntimeException {

public static final String DEFAULT_MSG = "The AndHowCompileProcessor found a problem"
+ " during compilation and threw a fatal exception - "
+ "See the error details listed nearby.";

private final String msg;
private final List<CompileProblem> problems;
private final Throwable cause;


/**
* Instance when there are one or more AndHow domain 'problems' with the
* code being compiled.
*
* Examples would include Properties that are not <code>static final</code>
* or too many init classes on the classpath.
*
* @param problems A list of problems found during compilation. This list
* instance is kept, so no modifications to the list should be made by the
* caller.
*/
public AndHowCompileException(List<CompileProblem> problems) {

cause = null;
msg = DEFAULT_MSG;

this.problems = (problems != null) ? problems : Collections.emptyList();
}

/**
* Instance when there is some unexpected, non-AndHow related exception.
*
* Example: Unwritable file system.
*
* @param message AndHow context description
* @param cause Error caught that caused the issue
*/
public AndHowCompileException(String message, Throwable cause) {
msg = message;
this.cause = cause;
this.problems = Collections.emptyList();
}

@Override
public synchronized Throwable getCause() {
return (cause != null) ? cause : super.getCause();
}


@Override
public String getMessage() {
return msg;
}

/**
* The list of AndHow CompileProblems discovered, if any.
*
* @return A non-null, by possibly empty list. Do not modify the returned list.
*/
public List<CompileProblem> getProblems() {
return problems;
}

}
Loading