Package net.mtrop.doom.util
Class RangeUtils
java.lang.Object
net.mtrop.doom.util.RangeUtils
Holds a series of helpful methods for testing data integrity for Doom map data export.
- Author:
- Matthew Tropiano
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
checkASCIIString
(String dataName, String value) Checks if a string's length is 8 or less or not null nor blank and convertible to ASCII.static void
checkBoolean
(String dataName, boolean flag, boolean value) Checks if a value is either true or false.static void
Checks if a value falls in the -128 to 127 range.static void
checkByteUnsigned
(String dataName, int value) Checks if a value falls in the 0 to 255 range.static void
checkEqual
(String dataName, float equalVal, float value) Checks if a value equals a particular floating-point value.static void
checkEqual
(String dataName, String equalVal, String value) Checks if a value equals a particular String value.static void
checkFalse
(String dataName, boolean value) Checks if a value is false.static void
checkNegativeOne
(String dataName, int value) Checks if a value is negative one.static void
checkNotNull
(String dataName, Object value) Checks if a value is not null.static void
checkRange
(String dataName, int min, int max, int value) Checks if a value falls in an inclusive range.static void
checkShort
(String dataName, int value) Checks if a value falls in the -32767 to 32768 range.static void
checkShortUnsigned
(String dataName, int value) Checks if a value falls in the 0 to 65535 range.static void
Checks if a value is true.static void
checkWhole
(String dataName, float value) Checks if a value is a whole number, without a mantissa.static void
Checks if a value is zero.
-
Method Details
-
checkNotNull
Checks if a value is not null.- Parameters:
dataName
- the name of the data field (appears in exception text).value
- the value to check.- Throws:
IllegalArgumentException
- if criteria not met.
-
checkRange
public static void checkRange(String dataName, int min, int max, int value) throws IllegalArgumentException Checks if a value falls in an inclusive range.- Parameters:
dataName
- the name of the data field (appears in exception text).min
- the minimum value.max
- the maximum value.value
- the value to check.- Throws:
IllegalArgumentException
- if criteria not met.
-
checkEqual
public static void checkEqual(String dataName, float equalVal, float value) throws IllegalArgumentException Checks if a value equals a particular floating-point value.- Parameters:
dataName
- the name of the data field (appears in exception text).equalVal
- the equality value.value
- the value to check.- Throws:
IllegalArgumentException
- if criteria not met.
-
checkEqual
public static void checkEqual(String dataName, String equalVal, String value) throws IllegalArgumentException Checks if a value equals a particular String value.- Parameters:
dataName
- the name of the data field (appears in exception text).equalVal
- the equality value.value
- the value to check.- Throws:
IllegalArgumentException
- if criteria not met.
-
checkBoolean
public static void checkBoolean(String dataName, boolean flag, boolean value) throws IllegalArgumentException Checks if a value is either true or false.- Parameters:
dataName
- the name of the data field (appears in exception text).flag
- the flag value.value
- the value to check.- Throws:
IllegalArgumentException
- if criteria not met.
-
checkWhole
Checks if a value is a whole number, without a mantissa.- Parameters:
dataName
- the name of the data field (appears in exception text).value
- the value to check.- Throws:
IllegalArgumentException
- if criteria not met.
-
checkZero
Checks if a value is zero.- Parameters:
dataName
- the name of the data field (appears in exception text).value
- the value to check.- Throws:
IllegalArgumentException
- if criteria not met.
-
checkNegativeOne
Checks if a value is negative one.- Parameters:
dataName
- the name of the data field (appears in exception text).value
- the value to check.- Throws:
IllegalArgumentException
- if criteria not met.
-
checkASCIIString
Checks if a string's length is 8 or less or not null nor blank and convertible to ASCII.- Parameters:
dataName
- the name of the data field (appears in exception text).value
- the value to check.- Throws:
IllegalArgumentException
- if criteria not met.
-
checkByteUnsigned
Checks if a value falls in the 0 to 255 range.- Parameters:
dataName
- the name of the data field (appears in exception text).value
- the value to check.- Throws:
IllegalArgumentException
- if criteria not met.
-
checkByte
Checks if a value falls in the -128 to 127 range.- Parameters:
dataName
- the name of the data field (appears in exception text).value
- the value to check.- Throws:
IllegalArgumentException
- if criteria not met.
-
checkShort
Checks if a value falls in the -32767 to 32768 range.- Parameters:
dataName
- the name of the data field (appears in exception text).value
- the value to check.- Throws:
IllegalArgumentException
- if criteria not met.
-
checkShortUnsigned
Checks if a value falls in the 0 to 65535 range.- Parameters:
dataName
- the name of the data field (appears in exception text).value
- the value to check.- Throws:
IllegalArgumentException
- if criteria not met.
-
checkTrue
Checks if a value is true.- Parameters:
dataName
- the name of the data field (appears in exception text).value
- the value to check.- Throws:
IllegalArgumentException
- if criteria not met.
-
checkFalse
Checks if a value is false.- Parameters:
dataName
- the name of the data field (appears in exception text).value
- the value to check.- Throws:
IllegalArgumentException
- if criteria not met.
-