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 | 20 |
1 files changed, 17 insertions, 3 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..848cad03 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); @@ -404,9 +414,8 @@ public final class Internal { } } - /** - * An empty byte array constant used in generated code. - */ + + /** An empty byte array constant used in generated code. */ public static final byte[] EMPTY_BYTE_ARRAY = new byte[0]; /** @@ -420,6 +429,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>}. * |