public interface FlaggableType<T> extends ValueType<T>
A FlaggableType could be used for a Property that is expected to be set true or false via a
command line argument just by its presence, e.g.:
java MyClass launch
If launch is an AndHow property using a FlaggableType
(i.e. FlagProp), launch will be considered true
just by its presence.
| Modifier and Type | Method and Description |
|---|---|
T |
parseFlag(String sourceValue)
Attempts to parse the passed String into the destination type with flag semantics.
|
cast, getDestinationType, parse, toStringT parseFlag(String sourceValue) throws ParsingException
This method behaves as ValueType.parse(String), but with these differences:
FlagProp for an example.ValueType.toString(Object)
This method should only be called by loaders that support Flags. For instance, loading a
non-null value from the properties file entry 'name = ' would be unexpected,
so a properties file loader should use the 'parse' method. However, a command line loader
would be expected to support flags, so could call this method instead of 'parse'.
This method may still throw a ParsingException, since non-null values may still be parsed.
As with ValueType.parse(String), all trimming (removing whitespace from around a value) should
be assumed to already have happened for the incoming sourceValue.
Implementations should be careful to ONLY throw a ParsingException - Integers and other types may throw other unchecked exceptions when trying to convert values, which should be handled in this method and rethrown as a ParsingException.
sourceValue - ParsingException - for any type of failure.Copyright © 2022. All rights reserved.