public class FlagProp extends PropertyBase<Boolean>
Use a FlagProp when you want a configuration parameter that is always true or false,
such as toggling a feature on or off. It can also be used when a configuration parameter should
work like a 'nix command line switch, which is 'on' just by being present, e.g.:
java MyClass enableAwesomeMode
If enableAwesomeMode is the name or alias of a FlagProp, that FlagProp will set
True simply by having its name as an argument. You can also explicitly set its value,
e.g. enableAwesomeMode=true or enableAwesomeMode=false. When set to a value,
a FlagProp behaves exactly like a BolProp.
Note: A FlagProp has it's special present == true behavior only
for the command line loader (i.e. StdMainStringArgsLoader.
(see note below)
A FlagProp is similar to a BolProp, but with these differences:
FlagProp.getValue() always return true or false. Thus,
A FlagProp will never throw a RequirementProblem error during configuration because
it always has a value.propertyName=false.
true).
If a name referring to a FlagProp is found in any loader other than the command line loader,
the value is parsed and handled exactly as if it were a BolProp.
If a name referring to a FlagProp is found on command line loader:
key=value and the value contains any non-whitespace,
the value is handled just as a BolProp would handle the value.
NOTE: The behavior of the FlagProp changed in release 0.5.0
Prior to 0.5.0, FlagProps' special present == true behavior applied to all loaders,
so a properties file that included the name of a FlagProp with no value would set it True.
This non-desirable behavior was fixed
for the 0.5.0 release.
| Modifier and Type | Class and Description |
|---|---|
static class |
FlagProp.FlagBuilder |
| Constructor and Description |
|---|
FlagProp(Boolean defaultValue,
String shortDesc,
List<Name> aliases,
PropertyType paramType,
ValueType<Boolean> valueType,
Trimmer trimmer,
String helpText) |
| Modifier and Type | Method and Description |
|---|---|
static FlagProp.FlagBuilder |
builder()
A chainable builder for this property that should terminate with
build() |
Boolean |
getValue()
Returns the effective value of this property.
|
getDefaultValue, getDescription, getExplicitValue, getHelpText, getPropertyType, getRequestedAliases, getTrimmer, getValidators, getValueType, isNonNullRequiredclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetCanonicalName, getInAliases, getOutAliases, getValueAsString, isExplicitlySetpublic Boolean getValue()
Propertypublic static FlagProp.FlagBuilder builder()
build()
Use as FlagProp.builder()...series of builder methods...build();
Copyright © 2022. All rights reserved.