Package io.flutter.util
Class Preconditions
- java.lang.Object
-
- io.flutter.util.Preconditions
-
public final class Preconditions extends Object
Static convenience methods that help a method or constructor check whether it was invoked correctly (that is, whether its preconditions were met).
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> T
checkNotNull(T reference)
Ensures that an object reference passed as a parameter to the calling method is not null.static void
checkState(boolean expression)
Ensures the truth of an expression involving the state of the calling instance.static void
checkState(boolean expression, Object errorMessage)
Ensures the truth of an expression involving the state of the calling instance.
-
-
-
Method Detail
-
checkNotNull
public static <T> T checkNotNull(T reference)
Ensures that an object reference passed as a parameter to the calling method is not null.- Parameters:
reference
- an object reference- Returns:
- the non-null reference that was validated
- Throws:
NullPointerException
- ifreference
is null
-
checkState
public static void checkState(boolean expression)
Ensures the truth of an expression involving the state of the calling instance.- Parameters:
expression
- a boolean expression that must be checked to be true- Throws:
IllegalStateException
- ifexpression
is false
-
checkState
public static void checkState(boolean expression, @Nullable Object errorMessage)
Ensures the truth of an expression involving the state of the calling instance.- Parameters:
expression
- a boolean expression that must be checked to be trueerrorMessage
- the exception message to use if the check fails; will be converted to a string usingString.valueOf(Object)
- Throws:
IllegalStateException
- ifexpression
is false
-
-