From 6f84b08e6439b20c2123bc6591f3c42f3d43260d Mon Sep 17 00:00:00 2001 From: Nathan Herring Date: Sat, 4 Dec 2021 15:44:45 -0800 Subject: [PATCH] style: Fix 2 ErrorProneStyle findings * Constructors and methods with the same name should appear sequentially with no other code in between. * This catch block catches an exception and re-throws another, but swallows the caught exception rather than setting it as a cause. This can make debugging harder. Courtesy of clshepherd/clrobot in the monorepo. Fixes #590. --- .../datastore/v1/client/DatastoreHelper.java | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/datastore-v1-proto-client/src/main/java/com/google/datastore/v1/client/DatastoreHelper.java b/datastore-v1-proto-client/src/main/java/com/google/datastore/v1/client/DatastoreHelper.java index ca265a230..04bd79f23 100644 --- a/datastore-v1-proto-client/src/main/java/com/google/datastore/v1/client/DatastoreHelper.java +++ b/datastore-v1-proto-client/src/main/java/com/google/datastore/v1/client/DatastoreHelper.java @@ -483,6 +483,16 @@ public static Value.Builder makeValue(Date date) { return Value.newBuilder().setTimestampValue(toTimestamp(date.getTime() * 1000L)); } + /** Makes a GeoPoint value. */ + public static Value.Builder makeValue(LatLng value) { + return Value.newBuilder().setGeoPointValue(value); + } + + /** Makes a GeoPoint value. */ + public static Value.Builder makeValue(LatLng.Builder value) { + return makeValue(value.build()); + } + private static Timestamp.Builder toTimestamp(long microseconds) { long seconds = microseconds / MICROSECONDS_PER_SECOND; long microsecondsRemainder = microseconds % MICROSECONDS_PER_SECOND; @@ -497,16 +507,6 @@ private static Timestamp.Builder toTimestamp(long microseconds) { .setNanos((int) microsecondsRemainder * NANOSECONDS_PER_MICROSECOND); } - /** Makes a GeoPoint value. */ - public static Value.Builder makeValue(LatLng value) { - return Value.newBuilder().setGeoPointValue(value); - } - - /** Makes a GeoPoint value. */ - public static Value.Builder makeValue(LatLng.Builder value) { - return makeValue(value.build()); - } - /** * Make a key from the specified path of kind/id-or-name pairs and/or Keys. * @@ -545,7 +545,8 @@ public static Key.Builder makeKey(Object... elements) { try { kind = (String) element; } catch (ClassCastException e) { - throw new IllegalArgumentException("Expected string or Key, got: " + element.getClass()); + throw new IllegalArgumentException( + "Expected string or Key, got: " + element.getClass(), e); } pathElement.setKind(kind); if (pathIndex + 1 < elements.length) {