public class StdFixedValueLoader extends BaseFixedValueLoader implements StandardLoader
AndHowInit interface during initialization to
read your configuration. That looks like this:
import org.yarnandtail.andhow.*;
import org.yarnandtail.andhow.property.StrProp;
public class SetFixedValues implements AndHowInit {
@Override public AndHowConfiguration getConfiguration() {
return StdConfig.instance()
.addFixedValue(MY_PROP, 23L); //MY_PROP is some visible property of type Long.
.addFixedValue("A_PROPERTY_NAME", "abc") //A name or alias of a Property works as well
//In both cases, the value (23L or "abc") must be of the same type as the Property or
//an error will be thrown.
}
}
Alternatively you can use AndHow.findConfig() at an application entry
point such as the main method.
StandardLoader's, this loader is intended to be auto-created
by AndHow. The set of standard loaders and their order can bet set
via the AndHowConfiguration.setStandardLoaders() methods.
Other loaders which don't implement the StandardLoader interface can
be inserted into the load order via the
AndHowConfiguration.insertLoaderBefore/After().unknownPropertyAProblem| Constructor and Description |
|---|
StdFixedValueLoader()
There is no reason to use the constructor in production application code
because AndHow creates a single instance on demand at runtime.
|
| Modifier and Type | Method and Description |
|---|---|
LoaderValues |
load(PropertyConfigurationInternal runtimeDef,
LoaderEnvironment environment,
ValidatedValuesWithContext existingValues)
Builds up a list of LoaderValues by loading property values from a configuration source.
|
getLoaderDialect, getLoaderType, getSpecificLoadDescription, isFlaggable, isTrimmingRequiredForStringValues, isUnknownPropertyAProblem, load, releaseResources, setUnknownPropertyAProblemattemptToAdd, attemptToAdd, attemptToAdd, attemptToAddIfNotDuplicate, createValue, findDuplicateProperty, getClassConfig, getConfigSamplePrinter, getInstanceConfig, mapNametoPropertyclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetClassConfig, getConfigSamplePrinter, getInstanceConfig, getLoaderDialect, getLoaderType, getSpecificLoadDescription, isFlaggable, isTrimmingRequiredForStringValues, releaseResourcespublic StdFixedValueLoader()
public LoaderValues load(PropertyConfigurationInternal runtimeDef, LoaderEnvironment environment, ValidatedValuesWithContext existingValues)
LoaderLoaders find and load values and associate them with the correct Property. If there is a problem while doing that, they register one or more LoaderProblems in the returned LoaderValues.
Validation of Property values is not Loader's responsibility and will be handled outside this method.
load in interface LoaderruntimeDef - The definition of all known Properties and naming metadata.environment - The environment (System Props, Env vars, fixed values) as
known to the Loader.existingValues - The values already set by prior loaders, which may configure
the behavior of this loader.Copyright © 2022. All rights reserved.