Package org.opentcs.util
Klasse Assertions
java.lang.Object
org.opentcs.util.Assertions
Utility methods for checking preconditions, postconditions etc..
-
Methodenübersicht
Modifizierer und TypMethodeBeschreibungstatic void
checkArgument
(boolean expression, String errorMessage) Ensures the given expression istrue
.static void
checkArgument
(boolean expression, String messageTemplate, Object... messageArgs) Ensures the given expression istrue
.static int
checkInRange
(int value, int minimum, int maximum) Ensures thatvalue
is not smaller thanminimum
and not greater thanmaximum
.static int
checkInRange
(int value, int minimum, int maximum, String valueName) Ensures thatvalue
is not smaller thanminimum
and not greater thanmaximum
.static long
checkInRange
(long value, long minimum, long maximum) Ensures thatvalue
is not smaller thanminimum
and not greater thanmaximum
.static long
checkInRange
(long value, long minimum, long maximum, String valueName) Ensures thatvalue
is not smaller thanminimum
and not greater thanmaximum
.static void
checkState
(boolean expression, String errorMessage) Ensures the given expression istrue
.static void
checkState
(boolean expression, String messageTemplate, Object... messageArgs) Ensures the given expression istrue
.
-
Methodendetails
-
checkArgument
public static void checkArgument(boolean expression, String errorMessage) throws IllegalArgumentException Ensures the given expression istrue
.- Parameter:
expression
- The expression to be checked.errorMessage
- An optional error message.- Löst aus:
IllegalArgumentException
- If the given expression is not true.
-
checkArgument
public static void checkArgument(boolean expression, String messageTemplate, @Nullable Object... messageArgs) throws IllegalArgumentException Ensures the given expression istrue
.- Parameter:
expression
- The expression to be checked.messageTemplate
- A formatting template for the error message.messageArgs
- The arguments to be formatted into the message template.- Löst aus:
IllegalArgumentException
- If the given expression is not true.
-
checkState
Ensures the given expression istrue
.- Parameter:
expression
- The expression to be checked.errorMessage
- An optional error message.- Löst aus:
IllegalStateException
- If the given expression is not true.
-
checkState
public static void checkState(boolean expression, String messageTemplate, @Nullable Object... messageArgs) throws IllegalStateException Ensures the given expression istrue
.- Parameter:
expression
- The expression to be checked.messageTemplate
- A formatting template for the error message.messageArgs
- The arguments to be formatted into the message template.- Löst aus:
IllegalStateException
- If the given expression is not true.
-
checkInRange
Ensures thatvalue
is not smaller thanminimum
and not greater thanmaximum
.- Parameter:
value
- The value to be checked.minimum
- The minimum value.maximum
- The maximum value.- Gibt zurück:
- The given value.
- Löst aus:
IllegalArgumentException
- If value is not within the given range.
-
checkInRange
public static int checkInRange(int value, int minimum, int maximum, String valueName) throws IllegalArgumentException Ensures thatvalue
is not smaller thanminimum
and not greater thanmaximum
.- Parameter:
value
- The value to be checked.minimum
- The minimum value.maximum
- The maximum value.valueName
- An optional name for the value to be used for the exception message.- Gibt zurück:
- The given value.
- Löst aus:
IllegalArgumentException
- If value is not within the given range.
-
checkInRange
public static long checkInRange(long value, long minimum, long maximum) throws IllegalArgumentException Ensures thatvalue
is not smaller thanminimum
and not greater thanmaximum
.- Parameter:
value
- The value to be checked.minimum
- The minimum value.maximum
- The maximum value.- Gibt zurück:
- The given value.
- Löst aus:
IllegalArgumentException
- If value is not within the given range.
-
checkInRange
public static long checkInRange(long value, long minimum, long maximum, String valueName) throws IllegalArgumentException Ensures thatvalue
is not smaller thanminimum
and not greater thanmaximum
.- Parameter:
value
- The value to be checked.minimum
- The minimum value.maximum
- The maximum value.valueName
- An optional name for the value to be used for the exception message.- Gibt zurück:
- The given value.
- Löst aus:
IllegalArgumentException
- If value is not within the given range.
-