diff options
Diffstat (limited to 'java/core/src/main/java/com/google/protobuf/Internal.java')
-rw-r--r-- | java/core/src/main/java/com/google/protobuf/Internal.java | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/java/core/src/main/java/com/google/protobuf/Internal.java b/java/core/src/main/java/com/google/protobuf/Internal.java index 3b4a0412..c234559c 100644 --- a/java/core/src/main/java/com/google/protobuf/Internal.java +++ b/java/core/src/main/java/com/google/protobuf/Internal.java @@ -60,6 +60,16 @@ public final class Internal { static final Charset ISO_8859_1 = Charset.forName("ISO-8859-1"); /** + * Throws an appropriate {@link NullPointerException} if the given objects is {@code null}. + */ + static <T> T checkNotNull(T obj, String message) { + if (obj == null) { + throw new NullPointerException(message); + } + return obj; + } + + /** * Helper called by generated code to construct default values for string * fields. * <p> |