public interface AndHowConfiguration<C extends AndHowConfiguration>
| Modifier and Type | Method and Description |
|---|---|
<T> C |
addFixedValue(Property<T> property,
T value)
Sets a fixed, non-configurable value for a Property.
|
C |
addFixedValue(String name,
Object value)
Sets a fixed, non-configurable value for a named Property.
|
List<Loader> |
buildLoaders() |
C |
classpathPropertiesNotRequired()
Sets the properties file on the classpath to be optional, the default.
|
C |
classpathPropertiesRequired()
If called to set this to 'required', a classpath properties file must
exist and be readable.
|
C |
filesystemPropFileNotRequired()
Sets the properties file on the filesystem to be optional, the default.
|
C |
filesystemPropFileRequired()
If called to set this to 'required', a non-null configured value for the
filesystem properties file must point to an existing, readable properties
file.
|
List<Class<? extends StandardLoader>> |
getDefaultLoaderList()
The default list of standard loaders, as a list of Classes that implement
StandardLoader |
LoaderEnvironment |
getLoaderEnvironment()
The environment for
Loaders when they load values. |
NamingStrategy |
getNamingStrategy()
Return the naming strategy used to form Property names, match them to values and display them.
|
List<GroupProxy> |
getRegisteredGroups()
Return a custom list of 'Groups' (classes or interfaces containing AndHow Properties)
to use instead of allowing the auto-discovery to find the Groups.
|
C |
insertLoaderAfter(Class<? extends StandardLoader> insertAfterThisLoader,
Loader loaderToInsert) |
C |
insertLoaderBefore(Class<? extends StandardLoader> insertBeforeThisLoader,
Loader loaderToInsert) |
C |
removeFixedValue(Property<?> property)
Removes a Property value set only via addFixedValue(Property
|
C |
removeFixedValue(String propertyNameOrAlias)
Removes a Property value set only via addFixedValue(String name, Object value)
from the list of fixed values.
|
C |
setClasspathPropFilePath(String classpathPropFilePathString)
Sets the classpath path to a properties file for the
StdPropFileOnClasspathLoader to read and load from. |
C |
setClasspathPropFilePath(StrProp classpathPropFilePathProperty)
Sets the classpath path via a StrProp (a Property of String type) to a
properties file for the
StdPropFileOnClasspathLoader to read and load from. |
C |
setCmdLineArgs(String[] commandLineArgs)
Sets the command line arguments, removing any previously set commandline args.
|
C |
setFilesystemPropFilePath(StrProp filesystemPropFilePath)
Sets the filesystem path via a StrProp (a Property of String type) to a
properties file for the StdPropFileOnFilesystemLoader to load.
|
C |
setStandardLoaders(Class<? extends StandardLoader>... newStandardLoaders) |
C |
setStandardLoaders(List<Class<? extends StandardLoader>> newStandardLoaders) |
List<GroupProxy> getRegisteredGroups()
ServiceLoader to discover all classes containing
AndHow Properties in conjunction with a generated manifest of those classes created at
compile time. Each class containing at least one AndHow Property is called a Group
and is represented by a GroupProxy object.
If this method returns non-null, then AndHow does not use this auto-discovery mechanism and just uses the returned list of GroupProxies. This is primarily for testing, where it is useful to test on only a small set of Groups and Properties.
Returning an empty list from this method would result in AndHow initializing with no registered Groups.
NamingStrategy getNamingStrategy()
CaseInsensitiveNaming is implemented.C setCmdLineArgs(String[] commandLineArgs)
commandLineArgs - <T> C addFixedValue(Property<T> property, T value)
addFixedValue methods will
through a DuplicatePropertyLoaderProblem if they refer to
the same Property.T - The type of Property and valueproperty - The property to set a value forvalue - The value to set.C removeFixedValue(Property<?> property)
property - A non-null property.C addFixedValue(String name, Object value)
addFixedValue methods will
through a DuplicatePropertyLoaderProblem if they refer to
the same Property.name - The canonical or alias name of Property, which is trimmed to null.value - The Object value to set, which must match the type of the Property.C removeFixedValue(String propertyNameOrAlias)
propertyNameOrAlias - The name or alias of a property.C setClasspathPropFilePath(String classpathPropFilePathString)
StdPropFileOnClasspathLoader to read and load from.
If no path is specified via one of the two setClasspathPropFilePath methods,
the default classpath of '/andhow.properties' is used.
As per Java convention, a path on the classpath can use dots or slashes to separate packages. However, if the file name itself contains dots, then the path must start with a slash and use slashes to separate packages.
Valid Examples:
classpathPropFilePathString - C setClasspathPropFilePath(StrProp classpathPropFilePathProperty)
StdPropFileOnClasspathLoader to read and load from.
If no path is specified via one of the two setClasspathPropFilePath methods,
the default classpath of '/andhow.properties' is used.
As per Java convention, a path on the classpath can use dots or slashes to separate packages.
However, if the file name itself contains dots, then the path must start with a slash and use
slashes to separate packages. Its common to have a '.properties' extension on the properties
file, so its good practice to add a validation rule to the StrProp used here to ensure it
mustStartWith("/").
Valid Examples of configured values:
classpathPropFilePathProperty - C classpathPropertiesRequired()
StdPropFileOnClasspathLoader.
Since the StdPropFileOnClasspathLoader has a default property file name,
/andhow.properties, setting this to 'required' means that either that
default file name or another that you configure instead must exist.C classpathPropertiesNotRequired()
classpathPropertiesRequired()C setFilesystemPropFilePath(StrProp filesystemPropFilePath)
filesystemPropFilePath - C filesystemPropFileRequired()
StdPropFileOnFilesystemLoader.
A RuntimeException will be thrown if this is set to 'required' and there
is a path specified which points to a file that does not exist.
Configuring a filesystem path is a two step process:setFilesystemPropFilePath methodC filesystemPropFileNotRequired()
setFilesystemPropFilePath(org.yarnandtail.andhow.property.StrProp)List<Class<? extends StandardLoader>> getDefaultLoaderList()
StandardLoader
The returned list is disconnected from the actual list of loaders - it is intended to be a starting point for applications that want to modify the list, then call setStandardLoaders().
Unlike other methods of this class, it does not fluently return a method to itself, so your code will need a AndHowConfiguration instance reference to use it, eg:
public class MyAppInitiation implements AndHowInit {
@Override
public AndHowConfiguration getConfiguration() {
AndHowConfiguration config = AndHow.findConfig();
List<Class<? extends StandardLoader>> sll = config.getDefaultLoaderList();
...do some rearranging of the list...
config.setStandardLoaders(sll) ...and go on to call other methods on config...
}
}
Note: AndHow version up to and including 0.4.1 had this method as a static method.
LoaderEnvironment getLoaderEnvironment()
Loaders when they load values.
Though this may be editable in the AndHowConfiguration, the instance returned
here should be immutable.
LoaderEnvironment.C setStandardLoaders(List<Class<? extends StandardLoader>> newStandardLoaders)
C setStandardLoaders(Class<? extends StandardLoader>... newStandardLoaders)
C insertLoaderBefore(Class<? extends StandardLoader> insertBeforeThisLoader, Loader loaderToInsert)
C insertLoaderAfter(Class<? extends StandardLoader> insertAfterThisLoader, Loader loaderToInsert)
Copyright © 2022. All rights reserved.