Class ApplicationPropertiesSugar
java.lang.Object
org.refcodes.properties.PropertiesSugar
org.refcodes.properties.ext.application.ApplicationPropertiesSugar
public class ApplicationPropertiesSugar
extends org.refcodes.properties.PropertiesSugar
Declarative syntactic sugar which may be statically imported in order to
allow declarative definitions for the construction of
ApplicationProperties (and the like).-
Method Summary
Modifier and TypeMethodDescriptionstatic ApplicationPropertiesFactory method to conveniently create a preconfiguredApplicationPropertiesinstance.static ApplicationPropertiesFactory method to conveniently create a preconfiguredApplicationPropertiesinstance.static ApplicationPropertiesFactory method to conveniently create a preconfiguredApplicationPropertiesinstance.static ApplicationPropertieswithInputStream(InputStream aInputStream) Factory method to conveniently create a preconfiguredApplicationPropertiesinstance.static ApplicationPropertieswithObfuscationMode(org.refcodes.runtime.SystemContext aMode) Factory method to conveniently create a preconfiguredApplicationPropertiesinstance.static ApplicationPropertieswithParseArgs(String[] aArgs) Factory method to conveniently create a preconfiguredApplicationPropertiesinstance.static ApplicationPropertieswithProperties(org.refcodes.properties.Properties aProperties) Factory method to conveniently create a preconfiguredApplicationPropertiesinstance.static ApplicationPropertieswithResourceClass(String aFilePath) Factory method to conveniently create a preconfiguredApplicationPropertiesinstance.static ApplicationPropertieswithRootArgsSyntax(org.refcodes.cli.Condition aRootArgsSyntax) Factory method to conveniently create a preconfiguredApplicationPropertiesinstance.static ApplicationPropertieswithRootOption(org.refcodes.cli.Option<?> aRootOption) Factory method to conveniently create a preconfiguredApplicationPropertiesinstance.static ApplicationPropertieswithSecret(String aSecret) Factory method to conveniently create a preconfiguredApplicationPropertiesinstance.static ApplicationPropertiesFactory method to conveniently create a preconfiguredApplicationPropertiesinstance.Methods inherited from class org.refcodes.properties.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
-
Method Details
-
fromApplicationProperties
Factory method to conveniently create a preconfiguredApplicationPropertiesinstance. Constructs aApplicationPropertiesinstance with noConditionfor parsing command line arguments. As no syntax notation is required by the constructor (no rootCondition), no syntax validation is done. Therefore the properties are heuristically determined from the provided command line arguments when invokingwithArgs(String[]).- Returns:
- The accordingly constructed
ApplicationPropertiesinstance.
-
withArgs
Factory method to conveniently create a preconfiguredApplicationPropertiesinstance. Constructs aApplicationPropertiesinstance with noConditionfor parsing command line arguments: As no syntax notation is required by the constructor (no rootCondition), 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
ApplicationPropertiesinstance.
-
withRootArgsSyntax
Factory method to conveniently create a preconfiguredApplicationPropertiesinstance. Constructs aApplicationPropertiesinstance with the givenConditionrepresenting the syntax to be used to parse command line arguments. Provide command line arguments viaApplicationProperties.evalArgs(String[])(and the like methods).- Parameters:
aRootArgsSyntax- The root condition being the node from which parsing the command line arguments starts. Parse the command line arguments viaApplicationProperties.evalArgs(String[]).- Returns:
- The accordingly constructed
ApplicationPropertiesinstance.
-
withRootOption
Factory method to conveniently create a preconfiguredApplicationPropertiesinstance. Constructs aApplicationPropertiesinstance with the givenOptionrepresenting the syntax to be used to parse command line arguments. Provide command line arguments viaApplicationProperties.evalArgs(String[])(and the like methods).- Parameters:
aRootOption- The root option being the node from which parsing the command line arguments starts. Parse the command line arguments viaApplicationProperties.evalArgs(String[]).- Returns:
- The accordingly constructed
ApplicationPropertiesinstance.
-
withObfuscationMode
Factory method to conveniently create a preconfiguredApplicationPropertiesinstance. Constructs theApplicationPropertieswith the given obfuscation mode- Parameters:
aMode- TheSystemContextspecifies 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
ApplicationPropertiesinstance.
-
withSecret
Factory method to conveniently create a preconfiguredApplicationPropertiesinstance. Constructs aApplicationPropertiesinstance with a custom secret for obfuscation.- Parameters:
aSecret- The secret to be used when encountering upon obfuscated properties.- Returns:
- The accordingly constructed
ApplicationPropertiesinstance.
-
withFile
Factory method to conveniently create a preconfiguredApplicationPropertiesinstance. 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 methodConfigLocator.getFolders().- Parameters:
aFile- The file of the properties to load.- Returns:
- The
ApplicationPropertiesinstance as of the builder pattern for chained method calls. - Throws:
IOException- thrown in case accessing or processing the properties file failed.ParseException- Signals that an error has been reached unexpectedly while parsing the data to be loaded.
-
withInputStream
public static ApplicationProperties withInputStream(InputStream aInputStream) throws IOException, ParseException Factory method to conveniently create a preconfiguredApplicationPropertiesinstance. Reads the properties from the givenInputStream.- Parameters:
aInputStream- TheInputStreamfrom which to read the properties.- Returns:
- The
ApplicationPropertiesinstance as of the builder pattern for chained method calls. - Throws:
IOException- thrown in case accessing or processing the properties file failed.ParseException- Signals that an error has been reached unexpectedly while parsing the data to be loaded.
-
withResourceClass
public static ApplicationProperties withResourceClass(String aFilePath) throws IOException, ParseException Factory method to conveniently create a preconfiguredApplicationPropertiesinstance. 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 methodConfigLocator.getFolders().- Parameters:
aFilePath- The file of the properties file to load.- Returns:
- The
ApplicationPropertiesinstance as of the builder pattern for chained method calls. - Throws:
IOException- thrown in case accessing or processing the properties file failed.ParseException- Signals that an error has been reached unexpectedly while parsing the data to be loaded.
-
withUrl
Factory method to conveniently create a preconfiguredApplicationPropertiesinstance. Loads the properties from the givenURL.- Parameters:
aUrl- TheURLfrom which to read the properties.- Returns:
- The
ApplicationPropertiesinstance as of the builder pattern for chained method calls. - Throws:
IOException- thrown in case accessing or processing the properties file failed.ParseException- Signals that an error has been reached unexpectedly while parsing the data to be loaded.
-
withParseArgs
public static ApplicationProperties withParseArgs(String[] aArgs) throws org.refcodes.cli.ArgsSyntaxException Factory method to conveniently create a preconfiguredApplicationPropertiesinstance. 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
ApplicationPropertiesinstance of the builder pattern to chain further method calls. - Throws:
org.refcodes.cli.ArgsSyntaxException- thrown in case of a command line arguments mismatch regarding provided and expected args.
-
withProperties
Factory method to conveniently create a preconfiguredApplicationPropertiesinstance. A hook for you to providePropertiesprogrammatically. The later you addProperties, the lower their precedence.- Parameters:
aProperties- ThePropertiesto be added.- Returns:
- The
ApplicationPropertiesinstance of the builder pattern to chain further method calls.
-