Flutter Engine
The Flutter Engine
Static Public Member Functions | List of all members
io.flutter.util.Preconditions Class Reference

Static Public Member Functions

static< T > T checkNotNull (T reference)
 
static void checkState (boolean expression)
 
static void checkState (boolean expression, @Nullable Object errorMessage)
 

Detailed Description

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.

Member Function Documentation

◆ 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
referencean object reference
Returns
the non-null reference that was validated
Exceptions
NullPointerExceptionif 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
expressiona boolean expression that must be checked to be true
Exceptions
IllegalStateExceptionif 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
expressiona boolean expression that must be checked to be true
errorMessagethe exception message to use if the check fails; will be converted to a string using String#valueOf(Object)
Exceptions
IllegalStateExceptionif 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: