Package io.flutter.util
Class Preconditions
java.lang.Object
io.flutter.util.Preconditions
Static convenience methods that help a method or constructor check whether it was invoked
correctly (that is, whether its preconditions were met).
-
Method Summary
Modifier and TypeMethodDescriptionstatic <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 Details
-
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
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
-