Class SimpleOptionMap
- java.lang.Object
-
- org.checkerframework.framework.test.SimpleOptionMap
-
public class SimpleOptionMap extends java.lang.Object
SimpleOptionMap is a very basic Option container. The keys of the Option container are the set of Options and the values are the arguments to those options if they exists: e.g.,
This class is mainly used by TestConfigurationBuilder to make working with existing options simpler and less error prone. It is not intended for a general Option container because users creating tests via source code can more easily manipulate the map whereas a lot of sugar would be needed to make this class usable from the command line.Map( "-AprintAllQualifiers" => null "-classpath" => "myDir1:myDir2" )
-
-
Constructor Summary
Constructors Constructor Description SimpleOptionMap()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addOption(java.lang.String option)
Adds an option that takes no argument.void
addOption(java.lang.String option, java.lang.String value)
Adds an option that takes an argument.void
addOptionIfValueNonEmpty(java.lang.String option, @Nullable java.lang.String value)
Adds the option only if value is a non-null, non-empty String.void
addOptions(java.lang.Iterable<java.lang.String> newOptions)
void
addOptions(java.util.Map<java.lang.String,@Nullable java.lang.String> options)
Adds all of the options in the given map to this one.void
addToPathOption(java.lang.String key, java.lang.String toAppend)
A method to easily add Strings to an option that takes a filepath as an argument.java.util.Map<java.lang.String,@Nullable java.lang.String>
getOptions()
Returns the map that backs this SimpleOptionMap.java.util.List<java.lang.String>
getOptionsAsList()
Creates a "flat" list representation of these options.void
removeOption(java.lang.String option)
Removes the specified option.void
setOptions(java.util.Map<java.lang.String,@Nullable java.lang.String> options)
Clears the current set of options and copies the input options to this map.
-
-
-
Method Detail
-
setOptions
public void setOptions(java.util.Map<java.lang.String,@Nullable java.lang.String> options)
Clears the current set of options and copies the input options to this map.- Parameters:
options
- the new options to use for this object
-
addToPathOption
public void addToPathOption(java.lang.String key, java.lang.String toAppend)
A method to easily add Strings to an option that takes a filepath as an argument.- Parameters:
key
- an option with an argument of the form "arg1[path-separator]arg2..." e.g., "-cp myDir:myDir2:myDir3"toAppend
- a string to append onto the path or, if the path is null/empty, the argument to the option indicated by key
-
addOption
public void addOption(java.lang.String option)
Adds an option that takes no argument.- Parameters:
option
- the no-argument option to add to this object
-
addOption
public void addOption(java.lang.String option, java.lang.String value)
Adds an option that takes an argument.- Parameters:
option
- the option to add to this objectvalue
- the argument to the option
-
addOptionIfValueNonEmpty
public void addOptionIfValueNonEmpty(java.lang.String option, @Nullable java.lang.String value)
Adds the option only if value is a non-null, non-empty String.- Parameters:
option
- the option to add to this objectvalue
- the argument to the option (or null)
-
addOptions
public void addOptions(java.util.Map<java.lang.String,@Nullable java.lang.String> options)
Adds all of the options in the given map to this one.- Parameters:
options
- the options to add to this object
-
addOptions
public void addOptions(java.lang.Iterable<java.lang.String> newOptions)
-
removeOption
public void removeOption(java.lang.String option)
Removes the specified option.- Parameters:
option
- the option to be removed from this object
-
getOptions
public java.util.Map<java.lang.String,@Nullable java.lang.String> getOptions()
Returns the map that backs this SimpleOptionMap.- Returns:
- the options in this object
-
getOptionsAsList
public java.util.List<java.lang.String> getOptionsAsList()
Creates a "flat" list representation of these options.- Returns:
- a list of the string representations of the options in this object
-
-