Module xaos.tools

Class Bundles


  • public class Bundles
    extends Object
    Utility method to be used with Bundle, BundleItem, and BundleItems annotations.

    Here and example of ho to use the annotations and this utility class:

       @Bundle( name = "Messages" )
       public class SomeClass {
    
         @BundleItem(
           key = "exception.message",
           comment = "Message used in the thrown illegal state exception.\n"
                   + "  {0} Message from the original exception.",
           message = "Operation not permitted [original message: {0}]."
         )
         public void doSomething() {
           try {
             ...
           } catch ( Exception ex ) {
             throw new IllegalStateException(
               Bundles.get(getClass(), "exception.message", ex.getMessage()),
               ex
             );
           }
         }
    
       }

    Note: when using Bundles the passed Class's package must must be opened to the xaos.tools module, i.e. it must be included into an opens statement in the module-info class.

    Author:
    claudio.rosati@esss.se