Skip to content

Commit 2bff28f

Browse files
committed
[ECO-5482] Updated LiveCounter interface as per spec
- Updated `increment`,`incrementAsync` method to take `number` as param - Updated `decrement`, `decrementAsync` method to take `number` as param
1 parent 6bfc6ea commit 2bff28f

2 files changed

Lines changed: 29 additions & 19 deletions

File tree

lib/src/main/java/io/ably/lib/objects/type/counter/LiveCounter.java

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,47 +14,57 @@
1414
public interface LiveCounter extends LiveCounterChange {
1515

1616
/**
17-
* Increments the value of the counter by 1.
17+
* Increments the value of the counter by the specified amount.
1818
* Send a COUNTER_INC operation to the realtime system to increment a value on this LiveCounter object.
1919
* This does not modify the underlying data of this LiveCounter object. Instead, the change will be applied when
2020
* the published COUNTER_INC operation is echoed back to the client and applied to the object following the regular
2121
* operation application procedure.
22+
* Spec: RTLC12
23+
*
24+
* @param amount the amount by which to increment the counter
25+
*/
26+
@Blocking
27+
void increment(@NotNull Number amount);
28+
29+
/**
30+
* Decrements the value of the counter by the specified amount.
31+
* An alias for calling {@link LiveCounter#increment(Number)} with a negative amount.
32+
* Spec: RTLC13
33+
*
34+
* @param amount the amount by which to decrement the counter
2235
*/
2336
@Blocking
24-
void increment();
37+
void decrement(@NotNull Number amount);
2538

2639
/**
27-
* Increments the value of the counter by 1 asynchronously.
40+
* Increments the value of the counter by the specified amount asynchronously.
2841
* Send a COUNTER_INC operation to the realtime system to increment a value on this LiveCounter object.
2942
* This does not modify the underlying data of this LiveCounter object. Instead, the change will be applied when
3043
* the published COUNTER_INC operation is echoed back to the client and applied to the object following the regular
3144
* operation application procedure.
45+
* Spec: RTLC12
3246
*
47+
* @param amount the amount by which to increment the counter
3348
* @param callback the callback to be invoked upon completion of the operation.
3449
*/
3550
@NonBlocking
36-
void incrementAsync(@NotNull Callback<Void> callback);
37-
38-
/**
39-
* Decrements the value of the counter by 1.
40-
* An alias for calling {@link LiveCounter#increment()} with a negative amount.
41-
*/
42-
@Blocking
43-
void decrement();
51+
void incrementAsync(@NotNull Number amount, @NotNull Callback<Void> callback);
4452

4553
/**
46-
* Decrements the value of the counter by 1 asynchronously.
47-
* An alias for calling {@link LiveCounter#increment()} with a negative amount.
54+
* Decrements the value of the counter by the specified amount asynchronously.
55+
* An alias for calling {@link LiveCounter#incrementAsync(Number, Callback)} with a negative amount.
56+
* Spec: RTLC13
4857
*
58+
* @param amount the amount by which to decrement the counter
4959
* @param callback the callback to be invoked upon completion of the operation.
5060
*/
5161
@NonBlocking
52-
void decrementAsync(@NotNull Callback<Void> callback);
62+
void decrementAsync(@NotNull Number amount, @NotNull Callback<Void> callback);
5363

5464
/**
5565
* Retrieves the current value of the counter.
5666
*
57-
* @return the current value of the counter as a Long.
67+
* @return the current value of the counter as a Double.
5868
*/
5969
@NotNull
6070
@Contract(pure = true) // Indicates this method does not modify the state of the object.

live-objects/src/main/kotlin/io/ably/lib/objects/type/livecounter/DefaultLiveCounter.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,19 @@ internal class DefaultLiveCounter private constructor(
4040
private val channelName = liveObjects.channelName
4141
private val adapter: LiveObjectsAdapter get() = liveObjects.adapter
4242

43-
override fun increment() {
43+
override fun increment(amount: Number) {
4444
TODO("Not yet implemented")
4545
}
4646

47-
override fun incrementAsync(callback: Callback<Void>) {
47+
override fun decrement(amount: Number) {
4848
TODO("Not yet implemented")
4949
}
5050

51-
override fun decrement() {
51+
override fun incrementAsync(amount: Number, callback: Callback<Void>) {
5252
TODO("Not yet implemented")
5353
}
5454

55-
override fun decrementAsync(callback: Callback<Void>) {
55+
override fun decrementAsync(amount: Number, callback: Callback<Void>) {
5656
TODO("Not yet implemented")
5757
}
5858

0 commit comments

Comments
 (0)