Commit 9b8f6589 authored by Jisi Liu's avatar Jisi Liu

Remove dependency on guava 20

parent d974cc2e
...@@ -30,7 +30,6 @@ ...@@ -30,7 +30,6 @@
package com.google.protobuf.util; package com.google.protobuf.util;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.math.IntMath.checkedAdd; import static com.google.common.math.IntMath.checkedAdd;
import static com.google.common.math.IntMath.checkedSubtract; import static com.google.common.math.IntMath.checkedSubtract;
import static com.google.common.math.LongMath.checkedAdd; import static com.google.common.math.LongMath.checkedAdd;
...@@ -135,14 +134,13 @@ public final class Durations { ...@@ -135,14 +134,13 @@ public final class Durations {
public static Duration checkValid(Duration duration) { public static Duration checkValid(Duration duration) {
long seconds = duration.getSeconds(); long seconds = duration.getSeconds();
int nanos = duration.getNanos(); int nanos = duration.getNanos();
checkArgument( if (!isValid(seconds, nanos)) {
isValid(seconds, nanos), throw new IllegalArgumentException(String.format(
"Duration is not valid. See proto definition for valid values. " "Duration is not valid. See proto definition for valid values. "
+ "Seconds (%s) must be in range [-315,576,000,000, +315,576,000,000]. " + "Seconds (%s) must be in range [-315,576,000,000, +315,576,000,000]. "
+ "Nanos (%s) must be in range [-999,999,999, +999,999,999]. " + "Nanos (%s) must be in range [-999,999,999, +999,999,999]. "
+ "Nanos must have the same sign as seconds", + "Nanos must have the same sign as seconds", seconds, nanos));
seconds, }
nanos);
return duration; return duration;
} }
......
...@@ -30,7 +30,6 @@ ...@@ -30,7 +30,6 @@
package com.google.protobuf.util; package com.google.protobuf.util;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.math.IntMath.checkedAdd; import static com.google.common.math.IntMath.checkedAdd;
import static com.google.common.math.IntMath.checkedSubtract; import static com.google.common.math.IntMath.checkedSubtract;
import static com.google.common.math.LongMath.checkedAdd; import static com.google.common.math.LongMath.checkedAdd;
...@@ -160,13 +159,12 @@ public final class Timestamps { ...@@ -160,13 +159,12 @@ public final class Timestamps {
public static Timestamp checkValid(Timestamp timestamp) { public static Timestamp checkValid(Timestamp timestamp) {
long seconds = timestamp.getSeconds(); long seconds = timestamp.getSeconds();
int nanos = timestamp.getNanos(); int nanos = timestamp.getNanos();
checkArgument( if (!isValid(seconds, nanos)) {
isValid(seconds, nanos), throw new IllegalArgumentException(String.format(
"Timestamp is not valid. See proto definition for valid values. " "Timestamp is not valid. See proto definition for valid values. "
+ "Seconds (%s) must be in range [-62,135,596,800, +253,402,300,799]. " + "Seconds (%s) must be in range [-62,135,596,800, +253,402,300,799]. "
+ "Nanos (%s) must be in range [0, +999,999,999].", + "Nanos (%s) must be in range [0, +999,999,999].", seconds, nanos));
seconds, }
nanos);
return timestamp; return timestamp;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment