Class Project
- Direct Known Subclasses:
GSProject
ConfigKey
whose value is validated against its ConfigParamInfo) plus free-form additional
properties. Goals read their configuration through the project. Subclasses declare the supported
configuration keys via getConfigKeys().-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringAdditional-property key under which the project name is stored. -
Constructor Summary
ConstructorsConstructorDescriptionCreates a project with the given name, which is also recorded as the "projectName" additional property. -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns the value of the given key as aboolean.protected voidcheckConfigProperties(Properties properties, GoalKey forGoal) Reports entries of the given properties that reference an unknown key, a key that is not valid for the given goal, or an invalid or out-of-range value.protected ConfigKeyconfigKeyFromName(String name) Returns the supported config key with the given name, ornullif there is none.configValue(ConfigKey key) Returns the configured value for the given key, or the key's default value if it is unset.doubleReturns the value of the given key as adouble.Returns a copy of the free-form additional properties.Returns the value of a free-form additional property.Returns the config parameters and the additional properties combined into a singleProperties.Returns the configured parameter values as properties keyed by config key name.protected abstract ConfigKey[]Returns all configuration keys supported by this project.protected org.apache.commons.logging.LogReturns the logger of this project.getName()Returns the project name.booleaninitConfigParam(ConfigKey key, Object value) Sets the value of the given config parameter if it is within the key's allowed range.protected voidinitConfigParam(ConfigKey key, Properties... propsArray) Initializes a single config parameter from the first property source that supplies a value the key accepts, falling back to the key's default value.protected voidinitConfigParams(Properties... propsArray) Initializes all supported config parameters from the given property sources.intintConfigValue(ConfigKey key) Returns the value of the given key as anint.protected booleanWhether an unknown configuration key, or a value its key cannot take, ends the run instead of being reported and dropped.voidLogs the effective configuration parameter map at info level, ordered by parameter name.longlongConfigValue(ConfigKey key) Returns the value of the given key as along.voidsetAdditionalProperty(String key, String value) Sets a free-form additional property.Returns the value of the given key as aString.
-
Field Details
-
PROJECT_NAME
Additional-property key under which the project name is stored.- See Also:
-
-
Constructor Details
-
Project
Creates a project with the given name, which is also recorded as the "projectName" additional property.- Parameters:
name- the project name
-
-
Method Details
-
setAdditionalProperty
Sets a free-form additional property.- Parameters:
key- the property keyvalue- the property value
-
getAdditionalProperty
Returns the value of a free-form additional property.- Parameters:
key- the property key- Returns:
- the property value, or
nullif unset
-
getAdditionalProperties
Returns a copy of the free-form additional properties.- Returns:
- a copy of the additional properties
-
getConfigAsProperties
Returns the configured parameter values as properties keyed by config key name.- Returns:
- the config parameters as properties
-
getAllAsProperties
Returns the config parameters and the additional properties combined into a singleProperties.- Returns:
- the config parameters and additional properties combined
-
getLogger
protected org.apache.commons.logging.Log getLogger()Returns the logger of this project.- Returns:
- the project logger
-
getConfigKeys
Returns all configuration keys supported by this project.- Returns:
- the supported configuration keys
-
configKeyFromName
Returns the supported config key with the given name, ornullif there is none.- Parameters:
name- the config key name to look up- Returns:
- the matching config key, or
nullif there is none
-
getName
Returns the project name.- Returns:
- the project name
-
configValue
Returns the configured value for the given key, or the key's default value if it is unset.- Parameters:
key- the config key- Returns:
- the configured value, or the key's default value if unset
-
intConfigValue
Returns the value of the given key as anint.- Parameters:
key- the config key- Returns:
- the value as an
int - Throws:
IllegalStateException- if the value is not anint
-
longConfigValue
Returns the value of the given key as along.- Parameters:
key- the config key- Returns:
- the value as a
long - Throws:
IllegalStateException- if the value is not along
-
booleanConfigValue
Returns the value of the given key as aboolean.- Parameters:
key- the config key- Returns:
- the value as a
boolean - Throws:
IllegalStateException- if the value is not aboolean
-
doubleConfigValue
Returns the value of the given key as adouble.- Parameters:
key- the config key- Returns:
- the value as a
double - Throws:
IllegalStateException- if the value is not adouble
-
stringConfigValue
Returns the value of the given key as aString.- Parameters:
key- the config key- Returns:
- the value as a
String - Throws:
IllegalStateException- if the value is not aString
-
initConfigParams
Initializes all supported config parameters from the given property sources.- Parameters:
propsArray- the property sources, in decreasing priority
-
initConfigParam
Initializes a single config parameter from the first property source that supplies a value the key accepts, falling back to the key's default value.- Parameters:
key- the config key to initializepropsArray- the property sources, in decreasing priority- Throws:
IllegalStateException- if even the default value is illegal
-
initConfigParam
Sets the value of the given config parameter if it is within the key's allowed range.- Parameters:
key- the config key to setvalue- the value to store- Returns:
- whether the value was accepted and stored
-
isStrictConfigCheck
protected boolean isStrictConfigCheck()Whether an unknown configuration key, or a value its key cannot take, ends the run instead of being reported and dropped.falsehere; a subclass that has a setting for it says so by overriding.- Returns:
- whether an unknown key or an invalid or out-of-range value is an error rather than a warning
-
checkConfigProperties
Reports entries of the given properties that reference an unknown key, a key that is not valid for the given goal, or an invalid or out-of-range value.Reports and carries on, the key keeping its default -- unless
isStrictConfigCheck()says otherwise, in which case an unknown key, an invalid value and a value out of range each end the run. Carrying on is not free: a database was once built for two and a half hours withrefseq.updateScope=allButExcludedin its configuration andALLin effect, because the running version did not yet know that value. The result looked plausible and answered a different question than the one asked. An unknown key -- a typo, or a key a later version dropped -- is the same kind of mistake: it has no effect, and the effect it was meant to have is missing from the result. Strict checking is for runs long enough that one wants to hear about that at the start rather than at the end.A key that belongs to another goal stays a warning either way, and it has to: one configuration file serves every goal of a project, and each goal checks the whole file, so a key meant for another goal is the normal case rather than an error. What counts as known is
getConfigKeys(), so a module adds its keys to the check by overriding that, asFTProjectdoes with theft.keys.- Parameters:
properties- the properties to checkforGoal- the goal the properties are checked against- Throws:
IllegalArgumentException- if a key is unknown or a value is invalid or out of range, and strict checking is on
-
logParamMap
public void logParamMap()Logs the effective configuration parameter map at info level, ordered by parameter name.The map itself is a
HashMap, so its own iteration order is the hash order of the config keys: neither their declaration order nor anything a reader can search in. Sorting by name makes two runs comparable line by line.
-