We have the following use cases
- A class needs a property and has a default value or handles the missing value somehow
- A class needs a value for a property to work
- A class may want to reconfigure itself upon a runtime property change
Currently we define 2. as our default and throw an Exception while we more often supply a default value of null and handle the returned value with null-checks somehow later.
Java 8 introduced Optional. This is a great class to handle use case 1. As this class provides mapping to different return types than String, it will allow us to provide us with cool API stuff:
For use case 3. we currently have no mechanism but simple polling. Java 8 gifts us FunctionalInterfaces and Predicates. Together with lambdas it will allow us to easily reconfigure classes in runtime.
Lets discuss this here and gather some ideas.