Skip to content

Commit 37721c0

Browse files
Make ServerValue.increment() public (#1417)
1 parent 068ca6f commit 37721c0

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

firebase-database/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# Unreleased
2+
- [feature] Added ServerValue.increment() to support atomic field value increments
3+
without transactions.
4+
15
# 19.2.0
26
- [changed] Added support for type wildcards in GenericTypeIndicator, expanding
37
our custom class serialization to include classes with wildcard generics

firebase-database/api.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,8 @@ package com.google.firebase.database {
188188
public class ServerValue {
189189
ctor public ServerValue();
190190
field @NonNull public static final java.util.Map<java.lang.String,java.lang.String> TIMESTAMP;
191+
field @NonNull public static final Object increment(double);
192+
field @NonNull public static final Object increment(long);
191193
}
192194

193195
@java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.RUNTIME) @java.lang.annotation.Target({java.lang.annotation.ElementType.TYPE}) public @interface ThrowOnExtraProperties {

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ public class ServerValue {
3434
createScalarServerValuePlaceholder(ServerValues.NAME_OP_TIMESTAMP);
3535

3636
/**
37-
* Adds the given delta to the current value at a location.
37+
* Returns a placeholder value that can be used to atomically increment the current database value
38+
* by the provided delta.
3839
*
3940
* <p>The delta must be an long or a double value. If the current value is not an integer or
4041
* double, or if the data does not yet exist, the transformation will set the data to the delta
@@ -46,12 +47,13 @@ public class ServerValue {
4647
* @return a placeholder value for modifying data atomically server-side.
4748
*/
4849
@NonNull
49-
static final Object increment(long delta) {
50+
public static final Object increment(long delta) {
5051
return createParameterizedServerValuePlaceholder(ServerValues.NAME_OP_INCREMENT, delta);
5152
}
5253

5354
/**
54-
* Adds the given delta to the current value at a location.
55+
* Returns a placeholder value that can be used to atomically increment the current database value
56+
* by the provided delta.
5557
*
5658
* <p>The delta must be an long or a double value. If the current value is not an integer or
5759
* double, or if the data does not yet exist, the transformation will set the data to the delta
@@ -63,7 +65,7 @@ static final Object increment(long delta) {
6365
* @return a placeholder value for modifying data atomically server-side.
6466
*/
6567
@NonNull
66-
static final Object increment(double delta) {
68+
public static final Object increment(double delta) {
6769
return createParameterizedServerValuePlaceholder(ServerValues.NAME_OP_INCREMENT, delta);
6870
}
6971

0 commit comments

Comments
 (0)