diff --git a/firebase-firestore/src/main/java/com/google/cloud/datastore/core/number/NumberComparisonHelper.java b/firebase-firestore/src/main/java/com/google/cloud/datastore/core/number/NumberComparisonHelper.java index 0d47360d3c5..b8527594d32 100644 --- a/firebase-firestore/src/main/java/com/google/cloud/datastore/core/number/NumberComparisonHelper.java +++ b/firebase-firestore/src/main/java/com/google/cloud/datastore/core/number/NumberComparisonHelper.java @@ -14,11 +14,7 @@ package com.google.cloud.datastore.core.number; -/** - * A utility class for comparing numbers. - * - * @hide - */ +/** A utility class for comparing numbers. */ public final class NumberComparisonHelper { // Long.MIN_VALUE has an exact representation as double, so the long lower bound is inclusive. @@ -33,10 +29,10 @@ public final class NumberComparisonHelper { public static final long MIN_SAFE_LONG = -MAX_SAFE_LONG; /** - * Compares a double and a long. Firestore ordering: NaN precedes all other numbers and equals - * itself, all zeroes are equal. + * Compares a double and a with Firestore query semantics: NaN precedes all other numbers and + * equals itself, all zeroes are equal. */ - public static int compareDoubleWithLong(double doubleValue, long longValue) { + public static int firestoreCompareDoubleWithLong(double doubleValue, long longValue) { // In Firestore NaN is defined to compare before all other numbers. if (Double.isNaN(doubleValue)) { return -1; @@ -60,7 +56,7 @@ public static int compareDoubleWithLong(double doubleValue, long longValue) { // At this point the long representations are equal but this could be due to rounding. double longAsDouble = (double) longValue; - return compareDoubles(doubleValue, longAsDouble); + return firestoreCompareDoubles(doubleValue, longAsDouble); } /** @@ -77,25 +73,14 @@ public static int compareLongs(long leftLong, long rightLong) { } } - /** Compares ints. See the comment to {@link #compareLongs} for rationale. */ - public static int compareInts(int leftInt, int rightInt) { - if (leftInt < rightInt) { - return -1; - } else if (leftInt > rightInt) { - return 1; - } else { - return 0; - } - } - /** - * Compares doubles. Firestore ordering: NaN precedes all other numbers and equals itself, all - * zeroes are equal. + * Compares doubles with Firestore query semantics: NaN precedes all other numbers and equals + * itself, all zeroes are equal. * * @return a negative integer, zero, or a positive integer as the first argument is less than, * equal to, or greater than the second. */ - public static int compareDoubles(double leftDouble, double rightDouble) { + public static int firestoreCompareDoubles(double leftDouble, double rightDouble) { // NaN sorts equal to itself and before any other number. if (leftDouble < rightDouble) { return -1; diff --git a/firebase-firestore/src/main/java/com/google/cloud/datastore/core/number/NumberIndexEncoder.java b/firebase-firestore/src/main/java/com/google/cloud/datastore/core/number/NumberIndexEncoder.java index 5df4dd001b1..0071ad31299 100644 --- a/firebase-firestore/src/main/java/com/google/cloud/datastore/core/number/NumberIndexEncoder.java +++ b/firebase-firestore/src/main/java/com/google/cloud/datastore/core/number/NumberIndexEncoder.java @@ -24,7 +24,6 @@ *

Implementation conforms to the UTF Style Encoding section of "Number Index Entry Encoding". * * @see "https://docs.google.com/document/d/1QX32BCTFWFS_4BneQHFRDnPb2ts04fYrm4Vgy0HLSBg/edit#" - * @hide */ public class NumberIndexEncoder { diff --git a/firebase-firestore/src/main/java/com/google/cloud/datastore/core/number/NumberParts.java b/firebase-firestore/src/main/java/com/google/cloud/datastore/core/number/NumberParts.java index 876f83543f5..e4dfe3c13fc 100644 --- a/firebase-firestore/src/main/java/com/google/cloud/datastore/core/number/NumberParts.java +++ b/firebase-firestore/src/main/java/com/google/cloud/datastore/core/number/NumberParts.java @@ -17,8 +17,6 @@ /** * The representation of a number that can accommodate the range of doubles and longs without loss * of precision. - * - * @hide */ public final class NumberParts { diff --git a/firebase-firestore/src/main/java/com/google/cloud/datastore/core/number/package-info.java b/firebase-firestore/src/main/java/com/google/cloud/datastore/core/number/package-info.java deleted file mode 100644 index 80ec5b2943d..00000000000 --- a/firebase-firestore/src/main/java/com/google/cloud/datastore/core/number/package-info.java +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2018 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -/** @hide */ -package com.google.cloud.datastore.storage.number; \ No newline at end of file diff --git a/firebase-firestore/src/main/java/com/google/firebase/firestore/util/Util.java b/firebase-firestore/src/main/java/com/google/firebase/firestore/util/Util.java index 18462cca389..2739bf1b799 100644 --- a/firebase-firestore/src/main/java/com/google/firebase/firestore/util/Util.java +++ b/firebase-firestore/src/main/java/com/google/firebase/firestore/util/Util.java @@ -86,17 +86,17 @@ public static int compareLongs(long i1, long i2) { /** Utility function to compare ints. See {@link #compareLongs} for rationale. */ public static int compareInts(int i1, int i2) { - return NumberComparisonHelper.compareInts(i1, i2); + return NumberComparisonHelper.compareLongs(i1, i2); } /** Utility function to compare doubles (using Firestore semantics for NaN). */ public static int compareDoubles(double i1, double i2) { - return NumberComparisonHelper.compareDoubles(i1, i2); + return NumberComparisonHelper.firestoreCompareDoubles(i1, i2); } /** Compares a double and a long (using Firestore semantics for NaN). */ public static int compareMixed(double doubleValue, long longValue) { - return NumberComparisonHelper.compareDoubleWithLong(doubleValue, longValue); + return NumberComparisonHelper.firestoreCompareDoubleWithLong(doubleValue, longValue); } @SuppressWarnings("unchecked")