Uploaded image for project: 'MyCoRe'
  1. MCR-1082

MCRConfiguration2 with support for Optional and EventListener

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Medium
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2018.05
    • Component/s: mycore-base
    • Labels:
      None
    • Sprint:

      Description

      We have the following use cases

      1. A class needs a property and has a default value or handles the missing value somehow
      2. A class needs a value for a property to work
      3. 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:

        getString(name).map(Integer::parseInt); //returns Optional<Integer>
      

      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.

        Attachments

          Issue links

            Activity

              People

              • Assignee:
                yagee Thomas Scheffler
                Reporter:
                yagee Thomas Scheffler
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: