Class RuntimePropertiesSugar


  • public class RuntimePropertiesSugar
    extends org.refcodes.configuration.PropertiesSugar
    Declarative syntactic sugar which may be statically imported in order to allow declarative definitions for the construction of RuntimeProperties (and the like).
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static RuntimeProperties fromRuntimeProperties()
      Factory method to conveniently create a pre-configured RuntimeProperties instance.
      static RuntimeProperties withArgs​(java.lang.String[] aArgs)
      Factory method to conveniently create a pre-configured RuntimeProperties instance.
      static RuntimeProperties withFile​(java.io.File aFile)
      Factory method to conveniently create a pre-configured RuntimeProperties instance.
      static RuntimeProperties withFilePath​(java.lang.String aFilePath)
      Factory method to conveniently create a pre-configured RuntimeProperties instance.
      static RuntimeProperties withInputStream​(java.io.InputStream aInputStream)
      Factory method to conveniently create a pre-configured RuntimeProperties instance.
      static RuntimeProperties withObfuscationMode​(org.refcodes.runtime.SystemContext aMode)
      Factory method to conveniently create a pre-configured RuntimeProperties instance.
      static RuntimeProperties withParseArgs​(java.lang.String[] aArgs)
      Factory method to conveniently create a pre-configured RuntimeProperties instance.
      static RuntimeProperties withProperties​(org.refcodes.configuration.Properties aProperties)
      Factory method to conveniently create a pre-configured RuntimeProperties instance.
      static RuntimeProperties withRootCondition​(org.refcodes.console.Condition aRootCondition)
      Factory method to conveniently create a pre-configured RuntimeProperties instance.
      static RuntimeProperties withSecret​(java.lang.String aSecret)
      Factory method to conveniently create a pre-configured RuntimeProperties instance.
      static RuntimeProperties withUrl​(java.net.URL aUrl)
      Factory method to conveniently create a pre-configured RuntimeProperties instance.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from class org.refcodes.configuration.PropertiesSugar

        fileToJavaProperties, fileToJavaProperties, fileToJsonProperties, fileToJsonProperties, fileToTomlProperties, fileToTomlProperties, fileToXmlProperties, fileToXmlProperties, fileToYamlProperties, fileToYamlProperties, from, from, fromEnvironmentVariables, fromProfile, fromProfile, fromProperties, fromSystemProperties, loadFromJavaProperties, loadFromJavaProperties, loadFromJavaProperties, loadFromJavaProperties, loadFromJsonProperties, loadFromJsonProperties, loadFromJsonProperties, loadFromJsonProperties, loadFromTomlProperties, loadFromTomlProperties, loadFromTomlProperties, loadFromTomlProperties, loadFromXmlProperties, loadFromXmlProperties, loadFromXmlProperties, loadFromXmlProperties, loadFromYamlProperties, loadFromYamlProperties, loadFromYamlProperties, loadFromYamlProperties, saveToJavaProperties, saveToJavaProperties, saveToJavaProperties, saveToJsonProperties, saveToJsonProperties, saveToJsonProperties, saveToTomlProperties, saveToTomlProperties, saveToTomlProperties, saveToXmlProperties, saveToXmlProperties, saveToXmlProperties, saveToYamlProperties, saveToYamlProperties, saveToYamlProperties, schedule, schedule, schedule, schedule, schedule, schedule, schedule, schedule, schedule, schedule, schedule, schedule, schedule, schedule, schedule, schedule, seekFromJavaProperties, seekFromJavaProperties, seekFromJsonProperties, seekFromJsonProperties, seekFromTomlProperties, seekFromTomlProperties, seekFromXmlProperties, seekFromXmlProperties, seekFromYamlProperties, seekFromYamlProperties, toNormalized, toNormalized, toPrecedence, toPropertiesBuilder, toPropertiesBuilder, toProperty
    • Constructor Detail

      • RuntimePropertiesSugar

        public RuntimePropertiesSugar()
    • Method Detail

      • fromRuntimeProperties

        public static RuntimeProperties fromRuntimeProperties()
        Factory method to conveniently create a pre-configured RuntimeProperties instance. Constructs a RuntimeProperties instance with no Condition for parsing command line arguments. As no syntax notation is required by the constructor (no root Condition), no syntax validation is done. Therefore the properties are heuristically determined from the provided command line arguments when invoking withArgs(String[]).
        Returns:
        The accordingly constructed RuntimeProperties instance.
      • withArgs

        public static RuntimeProperties withArgs​(java.lang.String[] aArgs)
        Factory method to conveniently create a pre-configured RuntimeProperties instance. Constructs a RuntimeProperties instance with no Condition for parsing command line arguments: As no syntax notation is required by the constructor (no root Condition), no syntax validation is done. Therefore the properties are heuristically determined from the provided command line arguments.
        Parameters:
        aArgs - The command line arguments to be evaluated.
        Returns:
        The accordingly constructed RuntimeProperties instance.
      • withRootCondition

        public static RuntimeProperties withRootCondition​(org.refcodes.console.Condition aRootCondition)
        Factory method to conveniently create a pre-configured RuntimeProperties instance. Constructs a RuntimeProperties instance with the given Condition representing the syntax to be used to parse command line arguments. Provide command line arguments via ArgsParserProperties.evalArgs(String[]) (and the like methods).
        Parameters:
        aRootCondition - The root condition being the node from which parsing the command line arguments starts. Parse the command line arguments via ArgsParserProperties.evalArgs(String[]).
        Returns:
        The accordingly constructed RuntimeProperties instance.
      • withObfuscationMode

        public static RuntimeProperties withObfuscationMode​(org.refcodes.runtime.SystemContext aMode)
        Factory method to conveniently create a pre-configured RuntimeProperties instance. Constructs the RuntimeProperties with the given obfuscation mode
        Parameters:
        aMode - The SystemContext specifies which level of obfuscation is to be used when encountering upon obfuscated properties: E.g. obfuscation may be bound to the host, the "secret" used for obfuscation being the same for all applications on the same host or obfuscation may be bound to the application, being different for different applications on the same host.
        Returns:
        The accordingly constructed RuntimeProperties instance.
      • withSecret

        public static RuntimeProperties withSecret​(java.lang.String aSecret)
        Factory method to conveniently create a pre-configured RuntimeProperties instance. Constructs a RuntimeProperties instance with a custom secret for obfuscation.
        Parameters:
        aSecret - The secret to be used when encountering upon obfuscated properties.
        Returns:
        The accordingly constructed RuntimeProperties instance.
      • withFile

        public static RuntimeProperties withFile​(java.io.File aFile)
                                          throws java.io.IOException,
                                                 java.text.ParseException
        Factory method to conveniently create a pre-configured RuntimeProperties instance. Loads a properties file from the file directly or (if not found) from first folder containing such a file as of the specification for the method ConfigLocator.getFolders().
        Parameters:
        aFile - The file of the properties to load.
        Returns:
        The RuntimeProperties instance as of the builder pattern for chained method calls.
        Throws:
        java.io.IOException - thrown in case accessing or processing the properties file failed.
        java.text.ParseException - Signals that an error has been reached unexpectedly while parsing the data to be loaded.
      • withInputStream

        public static RuntimeProperties withInputStream​(java.io.InputStream aInputStream)
                                                 throws java.io.IOException,
                                                        java.text.ParseException
        Factory method to conveniently create a pre-configured RuntimeProperties instance. Reads the properties from the given InputStream.
        Parameters:
        aInputStream - The InputStream from which to read the properties.
        Returns:
        The RuntimeProperties instance as of the builder pattern for chained method calls.
        Throws:
        java.io.IOException - thrown in case accessing or processing the properties file failed.
        java.text.ParseException - Signals that an error has been reached unexpectedly while parsing the data to be loaded.
      • withFilePath

        public static RuntimeProperties withFilePath​(java.lang.String aFilePath)
                                              throws java.io.IOException,
                                                     java.text.ParseException
        Factory method to conveniently create a pre-configured RuntimeProperties instance. Loads a properties file from the file directly or (if not found) from first folder containing such a file as of the specification for the method ConfigLocator.getFolders().
        Parameters:
        aFilePath - The file of the properties file to load.
        Returns:
        The RuntimeProperties instance as of the builder pattern for chained method calls.
        Throws:
        java.io.IOException - thrown in case accessing or processing the properties file failed.
        java.text.ParseException - Signals that an error has been reached unexpectedly while parsing the data to be loaded.
      • withUrl

        public static RuntimeProperties withUrl​(java.net.URL aUrl)
                                         throws java.io.IOException,
                                                java.text.ParseException
        Factory method to conveniently create a pre-configured RuntimeProperties instance. Loads the properties from the given URL.
        Parameters:
        aUrl - The URL from which to read the properties.
        Returns:
        The RuntimeProperties instance as of the builder pattern for chained method calls.
        Throws:
        java.io.IOException - thrown in case accessing or processing the properties file failed.
        java.text.ParseException - Signals that an error has been reached unexpectedly while parsing the data to be loaded.
      • withParseArgs

        public static RuntimeProperties withParseArgs​(java.lang.String[] aArgs)
                                               throws org.refcodes.console.UnknownArgsException,
                                                      org.refcodes.console.AmbiguousArgsException,
                                                      org.refcodes.console.SuperfluousArgsException,
                                                      org.refcodes.console.ParseArgsException
        Factory method to conveniently create a pre-configured RuntimeProperties instance. Evaluates the provided command line arguments and adds them with their according properties representation
        Parameters:
        aArgs - The command line arguments to be evaluated.
        Returns:
        The RuntimeProperties instance of the builder pattern to chain further method calls.
        Throws:
        org.refcodes.console.UnknownArgsException - Thrown in case not one command line argument matched regarding the provided args vs. the expected args.
        org.refcodes.console.AmbiguousArgsException - Thrown in case at least one command line argument is ambiguous regarding expected args vs. provided args.
        org.refcodes.console.SuperfluousArgsException - Thrown in case there were arguments found not being used (superfluous arguments).
        org.refcodes.console.ParseArgsException - Thrown in case the provided command line arguments do not respect the required syntax or cannot be converted to the required type
      • withProperties

        public static RuntimeProperties withProperties​(org.refcodes.configuration.Properties aProperties)
        Factory method to conveniently create a pre-configured RuntimeProperties instance. A hook for you to provide Properties programmatically. The later you add Properties, the lower their precedence.
        Parameters:
        aProperties - The Properties to be added.
        Returns:
        The RuntimeProperties instance of the builder pattern to chain further method calls.