aboutsummaryrefslogtreecommitdiff
path: root/java/core/src/main/java/com/google/protobuf/Internal.java
diff options
context:
space:
mode:
authorAdam Cozzette <acozzette@google.com>2017-04-27 14:55:53 -0700
committerAdam Cozzette <acozzette@google.com>2017-04-27 14:55:53 -0700
commit9053033a5076f82cf18b823c31f352e95e5bfd8d (patch)
tree1d2a2611f56e786d7c3e40b8fd1b2e3d9aff9025 /java/core/src/main/java/com/google/protobuf/Internal.java
parent067b1eec3bf852abaad0844999461baff8a5fdc8 (diff)
parenta6189acd18b00611c1dc7042299ad75486f08a1a (diff)
downloadprotobuf-9053033a5076f82cf18b823c31f352e95e5bfd8d.tar.gz
protobuf-9053033a5076f82cf18b823c31f352e95e5bfd8d.tar.bz2
protobuf-9053033a5076f82cf18b823c31f352e95e5bfd8d.zip
Merge remote-tracking branch 'remotes/google/3.3.x' into merge-3.3-to-master
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.java15
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>}.
*