public class SettingUtils
extends java.lang.Object
Constructor and Description |
---|
SettingUtils() |
Modifier and Type | Method and Description |
---|---|
static boolean |
checkBooleanWithDefault(java.lang.String settingValue,
java.lang.String settingKey,
boolean defaultValue)
Method that returns related boolean or default value if setting is empty.
|
static int |
checkIntegerWithDefault(java.lang.String settingValue,
java.lang.String settingKey,
int defaultValue)
Method that returns related integer or default value if setting is empty.
|
static long |
checkLongWithDefault(java.lang.String settingValue,
java.lang.String settingKey,
long defaultValue)
Method that returns related long or default value if setting is empty.
|
static boolean |
checkRequiredBoolean(java.lang.String settingValue,
java.lang.String settingKey)
Help method to parse a boolean for a required setting.
|
static int |
checkRequiredInteger(java.lang.String settingValue,
java.lang.String settingKey)
Help method to parse an integer for a required setting.
|
static long |
checkRequiredLong(java.lang.String settingValue,
java.lang.String settingKey)
Help method to parse an long for a required setting.
|
static java.lang.String |
checkRequiredString(java.lang.String settingValue,
java.lang.String settingKey)
Help method that checks that given setting isn't null or empty
otherwise it throws an InternalErrorException with error message
that related key should be set.
|
static java.lang.String |
checkStringWithDefault(java.lang.String settingValue,
java.lang.String defaultValue)
Method that returns related string or default value if setting is empty.
|
static boolean |
isEmpty(java.lang.String value)
Help method to see if string is null or only contains spaces.
|
public static java.lang.String checkRequiredString(java.lang.String settingValue, java.lang.String settingKey) throws InternalErrorException
settingValue
- the value to set.settingKey
- the key to use in error messageInternalErrorException
- if settingValue was empty.public static java.lang.String checkStringWithDefault(java.lang.String settingValue, java.lang.String defaultValue)
settingValue
- the value of settingdefaultValue
- the default value if not set or empty.public static int checkRequiredInteger(java.lang.String settingValue, java.lang.String settingKey) throws InternalErrorException
settingValue
- the value to convert to an integer.settingKey
- the key to use in error messageInternalErrorException
- if setting value was empty or non-integer.public static int checkIntegerWithDefault(java.lang.String settingValue, java.lang.String settingKey, int defaultValue) throws InternalErrorException
settingValue
- the value of settingsettingKey
- the related setting keydefaultValue
- the default value if not set or empty.InternalErrorException
- if setting value was empty or non-integer.public static long checkRequiredLong(java.lang.String settingValue, java.lang.String settingKey) throws InternalErrorException
settingValue
- the value to convert to an long.settingKey
- the key to use in error messageInternalErrorException
- if setting value was empty or non-integer.public static long checkLongWithDefault(java.lang.String settingValue, java.lang.String settingKey, long defaultValue) throws InternalErrorException
settingValue
- the value of settingsettingKey
- the related setting keydefaultValue
- the default value if not set or empty.InternalErrorException
- if setting value was empty or non-integer.public static boolean checkRequiredBoolean(java.lang.String settingValue, java.lang.String settingKey) throws InternalErrorException
settingValue
- the value to convert to an boolean.settingKey
- the key to use in error messageInternalErrorException
- if setting value was empty or non-boolean.public static boolean checkBooleanWithDefault(java.lang.String settingValue, java.lang.String settingKey, boolean defaultValue) throws InternalErrorException
settingValue
- the value of settingsettingKey
- the related setting keydefaultValue
- the default value if not set or empty.InternalErrorException
- if setting value was non-boolean.public static boolean isEmpty(java.lang.String value)
value
- the string to check