public class AndHowCore extends Object implements PropertyConfigurationInternal, ValidatedValues
The AndHow class is really a proxy for this class, which allows abstraction of the implementation and re-initialization during unit testing by swapping out the AndHowCore implementation while maintaining the AndHow singleton so references to it are stable.
EMPTY_PROPERTY_LIST| Constructor and Description |
|---|
AndHowCore(NamingStrategy naming,
List<Loader> loaders,
LoaderEnvironment loaderEnvironment,
List<GroupProxy> registeredGroups) |
| Modifier and Type | Method and Description |
|---|---|
static void |
checkForValuesWhichMustBeNonNull(PropertyConfigurationInternal config,
ValidatedValues values,
ProblemList<Problem> problems)
Adds a NonNullPropertyProblem for each null valued Property that is required to be non-null.
|
boolean |
containsUserGroups()
Returns true if any of the registered groups are user groups.
|
Stream<PropertyExport> |
export(Class<?>... exportClasses) |
List<EffectiveName> |
getAliases(Property<?> property)
All the effective 'in' & 'out' aliases for this property, not including the canonical name.
|
String |
getCanonicalName(Property<?> prop)
The canonical name of a
Property. |
<T> T |
getExplicitValue(Property<T> prop)
The value found and loaded for this value by a Loader.
|
List<ExportGroup> |
getExportGroups()
The list of ExportGroups, which handles exporting property values for use
outside the AndHow framework.
|
GroupProxy |
getGroupForProperty(Property<?> prop)
Finds the Group containing the specified Property.
|
NamingStrategy |
getNamingStrategy()
Defines how names are created for Properties.
|
List<Property<?>> |
getProperties()
Returns a complete list of all registered properties.
|
List<Property<?>> |
getPropertiesForGroup(GroupProxy group)
Returns a list of Properties registered in the passed group.
|
Property<?> |
getProperty(String name)
Finds a registered property by any recognized classpath style name,
including the canonical name or 'in' aliases.
|
List<GroupProxy> |
getPropertyGroups()
Returns a list of all registered groups.
|
<T> T |
getValue(Property<T> prop)
The effective value of the Property.
|
boolean |
isExplicitlySet(Property<?> prop)
True if the Property's value is explicitly set to a non-null value via one of the loaders.
|
public AndHowCore(NamingStrategy naming, List<Loader> loaders, LoaderEnvironment loaderEnvironment, List<GroupProxy> registeredGroups) throws AppFatalException
AppFatalExceptionpublic static void checkForValuesWhichMustBeNonNull(PropertyConfigurationInternal config, ValidatedValues values, ProblemList<Problem> problems)
All parameters are required to be non-null and will throw a null-pointer otherwise.
config - Configuration and metadata for all known Propertiesvalues - Values loaded for the Propertiesproblems - A list of Problems to append topublic Stream<PropertyExport> export(Class<?>... exportClasses) throws IllegalAccessException
IllegalAccessExceptionpublic boolean isExplicitlySet(Property<?> prop)
ValidatedValuesisExplicitlySet in interface ValidatedValuesprop - The property to checkpublic <T> T getExplicitValue(Property<T> prop) throws AndHowIllegalStateException.UnrecognizedPropertyException
If no non-null value was found by a loader for this property, null is returned. If the Property is not recognized, an IllegalArgumentException is thrown. In normal usage, AndHow would not expect an unrecognized Property, so this would indicate an unrecoverable state.
getExplicitValue in interface ValidatedValuesT - The return type of the Property.prop - The property to get the value forAndHowIllegalStateException.UnrecognizedPropertyException - if the Property is not recognized by AndHow.public <T> T getValue(Property<T> prop) throws AndHowIllegalStateException.UnrecognizedPropertyException
The effective value is the explicitly configured value, or if that is null, the default value. If the Property is not recognized, an IllegalArgumentException is thrown. In normal usage, AndHow would not expect an unrecognized Property, so this would indicate an unrecoverable state.
getValue in interface ValidatedValuesT - The return type of the Property.prop - The property to get the value for.AndHowIllegalStateException.UnrecognizedPropertyException - if the Property is not recognized by AndHow.public List<EffectiveName> getAliases(Property<?> property)
PropertyConfigurationThe returned aliases may differ from the original requested aliases in two ways:
NamingStrategy may modify 'In' aliases, e.g. convert them to uppercase for
case-insensitive matching. This method returns the modified 'In' aliases.getAliases in interface PropertyConfigurationproperty - The property to fetch naming information forEffectiveNames for this Property.Property.getInAliases(),
Property.getOutAliases(),
Property.getRequestedAliases()public String getCanonicalName(Property<?> prop)
PropertyConfigurationProperty.
Canonical Property names are the full Java classname of the class containing the Property, plus
the Property name, e.g. org.acme.myapp.MyClass.MyProperty. Properties contained in
inner classes and interfaces continue the same naming structure, e.g.
org.acme.myapp.MyClass.MyInnerClass.MyInnerInterface.MyProperty.
getCanonicalName in interface PropertyConfigurationprop - The Property to get the canonical name for.public GroupProxy getGroupForProperty(Property<?> prop)
PropertyConfigurationInternalgetGroupForProperty in interface PropertyConfigurationInternalprop - The property to get the PropertyGroup forpublic List<Property<?>> getPropertiesForGroup(GroupProxy group)
PropertyConfigurationInternalgetPropertiesForGroup in interface PropertyConfigurationInternalgroup - The group to get Properties forpublic Property<?> getProperty(String name)
PropertyConfigurationInternalmy.property and the URI style name, like my/property.
The URI style name is just a means of reading properties in another system -
for AndHow the URI style name is not considered an actual name.getProperty in interface PropertyConfigurationInternalname - A path to a property in the classpath style.public List<GroupProxy> getPropertyGroups()
PropertyConfigurationInternalgetPropertyGroups in interface PropertyConfigurationInternalpublic boolean containsUserGroups()
PropertyConfigurationInternalcontainsUserGroups in interface PropertyConfigurationInternalpublic List<Property<?>> getProperties()
PropertyConfigurationInternalgetProperties in interface PropertyConfigurationInternalpublic List<ExportGroup> getExportGroups()
PropertyConfigurationInternalgetExportGroups in interface PropertyConfigurationInternalpublic NamingStrategy getNamingStrategy()
PropertyConfigurationgetNamingStrategy in interface PropertyConfigurationCopyright © 2022. All rights reserved.