diff options
author | Pete Bentley <prb@google.com> | 2021-02-21 18:26:28 +0000 |
---|---|---|
committer | Pete Bentley <prb@google.com> | 2021-02-22 18:38:53 +0000 |
commit | aa1524950fb5fbffbb61d23c5442984cb731a1eb (patch) | |
tree | 7ce2c9779133dd053d314fdb25818acbbb4fa2be /src/main/java/org/junit/internal/Checks.java | |
parent | e938015d2d5a2157ed20eb622fcd9750a12bb4af (diff) | |
download | junit-aa1524950fb5fbffbb61d23c5442984cb731a1eb.tar.gz |
Upgrade external/junit to 4.13.2
Contains just the changes from 4.12 to 4.13.2 and undoes local
Android changes. Will re-patch those in in subsequent CLs.
Bug: 129054170
Test: m
Change-Id: I5ec909df6840f6c54cbab9c509c5addaee3f94e6
Diffstat (limited to 'src/main/java/org/junit/internal/Checks.java')
-rw-r--r-- | src/main/java/org/junit/internal/Checks.java | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/main/java/org/junit/internal/Checks.java b/src/main/java/org/junit/internal/Checks.java new file mode 100644 index 0000000..9724947 --- /dev/null +++ b/src/main/java/org/junit/internal/Checks.java @@ -0,0 +1,37 @@ +package org.junit.internal; + +/** @since 4.13 */ +public final class Checks { + + private Checks() {} + + /** + * Checks that the given value is not {@code null}. + * + * @param value object reference to check + * @return the passed-in value, if not {@code null} + * @throws NullPointerException if {@code value} is {@code null} + */ + public static <T> T notNull(T value) { + if (value == null) { + throw new NullPointerException(); + } + return value; + } + + /** + * Checks that the given value is not {@code null}, using the given message + * as the exception message if an exception is thrown. + * + * @param value object reference to check + * @param message message to use if {@code value} is {@code null} + * @return the passed-in value, if not {@code null} + * @throws NullPointerException if {@code value} is {@code null} + */ + public static <T> T notNull(T value, String message) { + if (value == null) { + throw new NullPointerException(message); + } + return value; + } +} |