public class IntegerUtil
extends java.lang.Object
Constructor and Description |
---|
IntegerUtil() |
Modifier and Type | Method and Description |
---|---|
static int |
checkMax(int value,
java.lang.String name,
int maxValue)
Check that an integer is equal or lower than a maximum value.
|
static int |
checkMin(int value,
java.lang.String name,
int minValue)
Check that an integer is equal or greater than a minimum value.
|
static int |
checkMinMax(int value,
java.lang.String name,
int minValue,
int maxValue)
Check that an integer is equal or between a minimum and a maximum value.
|
static int |
getInt(java.lang.Integer value)
Get the value of an
Integer . |
static int |
getInt(java.lang.Integer value,
int defaultValue)
Get the value of an
Integer . |
static int |
getInt(java.lang.String value)
Get the int value of an
String . |
static int |
getInt(java.lang.String value,
int defaultValue)
Get the int value of an
String . |
public static int getInt(java.lang.String value)
String
. If the String
couldn't be parsed 0 is returned.value
- The Integer
Integer
or 0 if it is not parseablepublic static int getInt(java.lang.String value, int defaultValue)
String
. If the String
couldn't be parsed default value is returned.value
- The Integer
defaultValue
- Default value to return if the parsing fails.Integer
or defaultValue if it is not parseablepublic static int getInt(java.lang.Integer value)
Integer
.value
- The Integer
Integer
or 0 if it is nullpublic static int getInt(java.lang.Integer value, int defaultValue)
Integer
.value
- The Integer
defaultValue
- The default value to return if the value is nullInteger
or defaultValue if it is nullpublic static int checkMin(int value, java.lang.String name, int minValue) throws NumberOutOfRangeException
value
- The value to checkname
- The name of the attribute to use if an exception is thrownminValue
- The minimum allowed valueNumberOutOfRangeException
- If the value lower than the minimumpublic static int checkMax(int value, java.lang.String name, int maxValue) throws NumberOutOfRangeException
value
- The value to checkname
- The name of the attribute to use if an exception is thrownmaxValue
- The maximum allowed valueNumberOutOfRangeException
- If the value greater than the maximumpublic static int checkMinMax(int value, java.lang.String name, int minValue, int maxValue) throws NumberOutOfRangeException
value
- The value to checkname
- The name of the attribute to use if an exception is thrownminValue
- The minimum allowed valuemaxValue
- The maximum allowed valueNumberOutOfRangeException
- If the value is outside the range