Static convenience methods that help a method or constructor check whether it was invoked correctly (that is, whether its preconditions were met).
Definition at line 13 of file Preconditions.java.
◆ checkNotNull()
static< T > T io.flutter.util.Preconditions.checkNotNull |
( |
T |
reference | ) |
|
|
inlinestatic |
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
- Exceptions
-
NullPointerException | if reference is null |
Definition at line 23 of file Preconditions.java.
23 {
24 if (reference == null) {
25 throw new NullPointerException();
26 }
27 return reference;
28 }
◆ checkState() [1/2]
static void io.flutter.util.Preconditions.checkState |
( |
boolean |
expression | ) |
|
|
inlinestatic |
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 |
- Exceptions
-
IllegalStateException | if expression is false |
Definition at line 36 of file Preconditions.java.
36 {
37 if (!expression) {
38 throw new IllegalStateException();
39 }
40 }
◆ checkState() [2/2]
static void io.flutter.util.Preconditions.checkState |
( |
boolean |
expression, |
|
|
@Nullable Object |
errorMessage |
|
) |
| |
|
inlinestatic |
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 |
errorMessage | the exception message to use if the check fails; will be converted to a string using String#valueOf(Object) |
- Exceptions
-
IllegalStateException | if expression is false |
Definition at line 50 of file Preconditions.java.
50 {
51 if (!expression) {
52 throw new IllegalStateException(String.valueOf(errorMessage));
53 }
54 }
The documentation for this class was generated from the following file: