Skip to content

Commit 018e32d

Browse files
committed
cleanup
1 parent 6ea4744 commit 018e32d

File tree

3 files changed

+33
-33
lines changed

3 files changed

+33
-33
lines changed

firebase-database/src/main/java/com/google/firebase/database/Query.java

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -479,10 +479,10 @@ private Query startAt(Node node, String key) {
479479
}
480480

481481
/**
482-
* Create a query constrained to only return child nodes with a value greater than the given
483-
* value, using the given orderBy directive or priority as default.
482+
* Create a query constrained to only return child nodes with a value less than the given value,
483+
* using the given orderBy directive or priority as default.
484484
*
485-
* @param value The value to start at, exclusive
485+
* @param value The value to end at, exclusive
486486
* @return A Query with the new constraint
487487
* @since 19.6
488488
*/
@@ -492,10 +492,10 @@ public Query endBefore(@Nullable String value) {
492492
}
493493

494494
/**
495-
* Create a query constrained to only return child nodes with a value greater than the given
496-
* value, using the given orderBy directive or priority as default.
495+
* Create a query constrained to only return child nodes with a value less than the given value,
496+
* using the given orderBy directive or priority as default.
497497
*
498-
* @param value The value to start at, exclusive
498+
* @param value The value to end at, exclusive
499499
* @return A Query with the new constraint
500500
* @since 19.6
501501
*/
@@ -505,10 +505,10 @@ public Query endBefore(double value) {
505505
}
506506

507507
/**
508-
* Create a query constrained to only return child nodes with a value greater than the given
509-
* value, using the given orderBy directive or priority as default.
508+
* Create a query constrained to only return child nodes with a value less than the given value,
509+
* using the given orderBy directive or priority as default.
510510
*
511-
* @param value The value to start at, exclusive
511+
* @param value The value to end at, exclusive
512512
* @return A Query with the new constraint
513513
* @since 19.6
514514
*/
@@ -518,12 +518,12 @@ public Query endBefore(boolean value) {
518518
}
519519

520520
/**
521-
* Create a query constrained to only return child nodes with a value greater than the given
522-
* value, using the given orderBy directive or priority as default, and additionally only child
523-
* nodes with a key greater than or equal to the given key.
521+
* Create a query constrained to only return child nodes with a value less than or equal to the
522+
* given value, using the given orderBy directive or priority as default, and additionally only
523+
* child nodes with a key less than the given key.
524524
*
525-
* @param value The priority to start at
526-
* @param key The key to start at, exclusive
525+
* @param value The value to end at
526+
* @param key The key to end at, exclusive
527527
* @return A Query with the new constraint
528528
* @since 19.6
529529
*/
@@ -535,12 +535,12 @@ public Query endBefore(@Nullable String value, @Nullable String key) {
535535
}
536536

537537
/**
538-
* Create a query constrained to only return child nodes with a value greater than the given
539-
* value, using the given orderBy directive or priority as default, and additionally only child
540-
* nodes with a key greater than or equal to the given key.
538+
* Create a query constrained to only return child nodes with a value less than or equal to the
539+
* given value, using the given orderBy directive or priority as default, and additionally only
540+
* child nodes with a key less than the given key.
541541
*
542-
* @param value The priority to start at
543-
* @param key The key name to start at, exclusive
542+
* @param value The value to end at
543+
* @param key The key to end at, exclusive
544544
* @return A Query with the new constraint
545545
* @since 19.6
546546
*/
@@ -550,12 +550,12 @@ public Query endBefore(double value, @Nullable String key) {
550550
}
551551

552552
/**
553-
* Create a query constrained to only return child nodes with a value greater than the given
554-
* value, using the given orderBy directive or priority as default, and additionally only child
555-
* nodes with a key greater than or equal to the given key.
553+
* Create a query constrained to only return child nodes with a value less than or equal to the
554+
* given value, using the given orderBy directive or priority as default, and additionally only
555+
* child nodes with a key less than the given key.
556556
*
557-
* @param value The priority to start at
558-
* @param key The key to start at, exclusive
557+
* @param value The value to end at
558+
* @param key The key to end at, exclusive
559559
* @return A Query with the new constraint
560560
* @since 19.6
561561
*/

firebase-database/src/main/java/com/google/firebase/database/core/utilities/PushIdGenerator.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import static com.google.firebase.database.core.utilities.Utilities.tryParseInt;
1919

2020
import com.google.firebase.database.snapshot.ChildKey;
21-
import java.util.Collections;
2221
import java.util.Random;
2322

2423
public class PushIdGenerator {
@@ -91,7 +90,9 @@ public static final String predecessor(String key) {
9190
next.setCharAt(
9291
next.length() - 1,
9392
PUSH_CHARS.charAt(PUSH_CHARS.indexOf(next.charAt(next.length() - 1)) - 1));
94-
return next.append(Collections.nCopies(MAX_PUSH_CHAR, MAX_KEY_LEN - next.length())).toString();
93+
return next.append(
94+
new String(new char[MAX_KEY_LEN - next.length()]).replace("\0", "" + MAX_PUSH_CHAR))
95+
.toString();
9596
};
9697

9798
public static final String successor(String key) {

firebase-database/src/test/java/com/google/firebase/database/PushIdGeneratorTest.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,17 +61,16 @@ public void testSuccessorBasic() {
6161
@Test
6262
public void testPredecessorSpecialValue() {
6363
assertEquals(
64-
PushIdGenerator.predecessor(String.valueOf(MIN_PUSH_CHAR)),
65-
String.valueOf(Integer.MAX_VALUE));
66-
assertEquals(PushIdGenerator.predecessor(String.valueOf(Integer.MIN_VALUE)), MIN_KEY_NAME);
64+
String.valueOf(Integer.MAX_VALUE),
65+
PushIdGenerator.predecessor(String.valueOf(MIN_PUSH_CHAR)));
66+
assertEquals(MIN_KEY_NAME, PushIdGenerator.predecessor(String.valueOf(Integer.MIN_VALUE)));
6767
}
6868

6969
@Test
7070
public void testPredecessorBasicValue() {
7171
assertEquals(
72-
PushIdGenerator.predecessor("abc"),
73-
"abb"
74-
+ StringUtils.repeat(Character.toString(MAX_PUSH_CHAR), MAX_KEY_LEN - "abc".length()));
75-
assertEquals(PushIdGenerator.predecessor("abc" + MIN_PUSH_CHAR), "abc");
72+
"abb" + StringUtils.repeat(Character.toString(MAX_PUSH_CHAR), MAX_KEY_LEN - "abc".length()),
73+
PushIdGenerator.predecessor("abc"));
74+
assertEquals("abc", PushIdGenerator.predecessor("abc" + MIN_PUSH_CHAR));
7675
}
7776
}

0 commit comments

Comments
 (0)