Class ErrorProneFlags
- All Implemented Interfaces:
Serializable
public final class ErrorProneFlags extends Object implements Serializable
All get* methods return an Optional<*>
containing the value for the given key, or
empty if the flag is unset.
To access ErrorProneFlags from a BugChecker class, add a constructor to the class that takes one parameter of type ErrorProneFlags.
See documentation for full syntax description.
- See Also:
- Serialized Form
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ErrorProneFlags.Builder
Builder for Error Prone command-line flags object. -
Field Summary
-
Method Summary
Modifier and Type Method Description static ErrorProneFlags.Builder
builder()
static ErrorProneFlags
empty()
static ErrorProneFlags
fromMap(Map<String,String> flagsMap)
Optional<String>
get(String key)
Gets flag value for the given key as a String, wrapped in anOptional
, which is empty if the flag is unset.Optional<Boolean>
getBoolean(String key)
Gets the flag value for the given key as a Boolean, wrapped in anOptional
, which is empty if the flag is unset.<T extends Enum<T>>
Optional<T>getEnum(String key, Class<T> clazz)
Gets the flag value for an enum of the given type, wrapped in anOptional
, which is empty if the flag is unset.<T extends Enum<T>>
Optional<com.google.common.collect.ImmutableSet<T>>getEnumSet(String key, Class<T> clazz)
Gets the flag value for a comma-separated set of enums of the given type, wrapped in anOptional
, which is empty if the flag is unset.com.google.common.collect.ImmutableMap<String,String>
getFlagsMap()
Optional<Integer>
getInteger(String key)
Gets the flag value for the given key as an Integer, wrapped in anOptional
, which is empty if the flag is unset.Optional<List<String>>
getList(String key)
Optional<Set<String>>
getSet(String key)
boolean
isEmpty()
Whether this Flags object is empty, i.e.ErrorProneFlags
plus(ErrorProneFlags other)
Returns a new ErrorProneFlags object with the values of two ErrorProneFlags objects added together.
-
Field Details
-
PREFIX
- See Also:
- Constant Field Values
-
-
Method Details
-
empty
-
fromMap
-
getFlagsMap
-
get
Gets flag value for the given key as a String, wrapped in anOptional
, which is empty if the flag is unset. -
getBoolean
Gets the flag value for the given key as a Boolean, wrapped in anOptional
, which is empty if the flag is unset.The value within the
Optional
will betrue
if the flag's value is "true",false
for "false", both case insensitive. If the value is neither "true" nor "false", throws anIllegalArgumentException
.Note that any flag set without a value, e.g.
-XepOpt:FlagValue
, will be "true". -
getEnum
Gets the flag value for an enum of the given type, wrapped in anOptional
, which is empty if the flag is unset. -
getEnumSet
public <T extends Enum<T>> Optional<com.google.common.collect.ImmutableSet<T>> getEnumSet(String key, Class<T> clazz)Gets the flag value for a comma-separated set of enums of the given type, wrapped in anOptional
, which is empty if the flag is unset. If the flag is explicitly set to empty, an empty set will be returned. -
getInteger
Gets the flag value for the given key as an Integer, wrapped in anOptional
, which is empty if the flag is unset.If the flag's value cannot be interpreted as an Integer, throws a
NumberFormatException
(note: float values will *not* be interpreted as integers and will throw an exception!) -
getList
-
getSet
-
isEmpty
public boolean isEmpty()Whether this Flags object is empty, i.e. no flags have been set. -
plus
Returns a new ErrorProneFlags object with the values of two ErrorProneFlags objects added together. For flags that appear in both instances, the values inother
overridethis
. -
builder
-