Skip to content

Make ServerValue.increment() public #1417

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions firebase-database/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Unreleased
- [feature] Added ServerValue.increment() to support atomic field value increments
without transactions.

# 19.2.0
- [changed] Added support for type wildcards in GenericTypeIndicator, expanding
our custom class serialization to include classes with wildcard generics
Expand Down
2 changes: 2 additions & 0 deletions firebase-database/api.txt
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,8 @@ package com.google.firebase.database {
public class ServerValue {
ctor public ServerValue();
field @NonNull public static final java.util.Map<java.lang.String,java.lang.String> TIMESTAMP;
field @NonNull public static final Object increment(double);
field @NonNull public static final Object increment(long);
}

@java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.RUNTIME) @java.lang.annotation.Target({java.lang.annotation.ElementType.TYPE}) public @interface ThrowOnExtraProperties {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ public class ServerValue {
createScalarServerValuePlaceholder(ServerValues.NAME_OP_TIMESTAMP);

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

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

Expand Down