| | |
| | | /**
|
| | | * SettingModel represents a setting and all its metadata: name, current value,
|
| | | * default value, description, and directives.
|
| | | * |
| | | *
|
| | | * @author James Moger
|
| | | */
|
| | | public class SettingModel implements Serializable {
|
| | |
| | |
|
| | | /**
|
| | | * Returns true if the current value is the default value.
|
| | | * |
| | | *
|
| | | * @return true if current value is the default value
|
| | | */
|
| | | public boolean isDefaultValue() {
|
| | |
| | | /**
|
| | | * Returns the boolean value for the currentValue. If the currentValue can
|
| | | * not be interpreted as a boolean, the defaultValue is returned.
|
| | | * |
| | | *
|
| | | * @param defaultValue
|
| | | * @return key value or defaultValue
|
| | | */
|
| | |
| | | /**
|
| | | * Returns the integer value for the currentValue. If the currentValue can
|
| | | * not be interpreted as an integer, the defaultValue is returned.
|
| | | * |
| | | *
|
| | | * @param defaultValue
|
| | | * @return key value or defaultValue
|
| | | */
|
| | |
| | | /**
|
| | | * Returns the char value for currentValue. If the currentValue can not be
|
| | | * interpreted as a char, the defaultValue is returned.
|
| | | * |
| | | *
|
| | | * @param defaultValue
|
| | | * @return key value or defaultValue
|
| | | */
|
| | |
| | | /**
|
| | | * Returns the string value for currentValue. If the currentValue is null,
|
| | | * the defaultValue is returned.
|
| | | * |
| | | *
|
| | | * @param defaultValue
|
| | | * @return key value or defaultValue
|
| | | */
|
| | |
| | |
|
| | | /**
|
| | | * Returns a list of space-separated strings from the specified key.
|
| | | * |
| | | *
|
| | | * @return list of strings
|
| | | */
|
| | | public List<String> getStrings() {
|
| | |
| | | /**
|
| | | * Returns a list of strings from the currentValue using the specified
|
| | | * string separator.
|
| | | * |
| | | *
|
| | | * @param separator
|
| | | * @return list of strings
|
| | | */
|
| | |
| | | strings = StringUtils.getStringsFromValue(currentValue, separator);
|
| | | return strings;
|
| | | }
|
| | | |
| | |
|
| | | /**
|
| | | * Returns a map of strings from the current value.
|
| | | * |
| | | *
|
| | | * @return map of string, string
|
| | | */
|
| | | public Map<String, String> getMap() {
|
| | |
| | | for (String string : getStrings()) {
|
| | | String[] kvp = string.split("=", 2);
|
| | | String key = kvp[0];
|
| | | String value = kvp[1]; |
| | | String value = kvp[1];
|
| | | map.put(key, value);
|
| | | }
|
| | | return map;
|