diff options
author | Feng Xiao <xfxyjwf@gmail.com> | 2017-03-29 14:32:48 -0700 |
---|---|---|
committer | Feng Xiao <xfxyjwf@gmail.com> | 2017-03-29 14:33:05 -0700 |
commit | d36c0c538a545fac5d9db6ba65c525246d4efa95 (patch) | |
tree | 3fd29af0f137dfaf5df892723e60600f674392b3 /java/core/src/main/java/com/google/protobuf/Internal.java | |
parent | 4a0dd03e52e09332c8fd0f8f26a8e0ae9f911182 (diff) |
Down-integrate from google3.
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 | 15 |
1 files changed, 15 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 c234559c..36bdece3 100644 --- a/java/core/src/main/java/com/google/protobuf/Internal.java +++ b/java/core/src/main/java/com/google/protobuf/Internal.java @@ -62,6 +62,16 @@ public final class Internal { /** * Throws an appropriate {@link NullPointerException} if the given objects is {@code null}. */ + static <T> T checkNotNull(T obj) { + if (obj == null) { + throw new NullPointerException(); + } + return obj; + } + + /** + * 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); @@ -420,6 +430,11 @@ public final class Internal { CodedInputStream.newInstance(EMPTY_BYTE_ARRAY); + /** Helper method to merge two MessageLite instances. */ + static Object mergeMessage(Object destination, Object source) { + return ((MessageLite) destination).toBuilder().mergeFrom((MessageLite) source).buildPartial(); + } + /** * Provides an immutable view of {@code List<T>} around a {@code List<F>}. * |