public class Counter extends Object
To define a field of type Counter
, annotate the field's getter method as a normal field using
@JField
. No setter method should be defined.
Counter fields do not support indexing or change listeners.
Note: during schema version change notification, counter field values appear as plain long
values.
Modifier and Type | Method and Description |
---|---|
void |
adjust(long offset)
Adjust this counter's value by the specified amount.
|
void |
decrement()
Decrement this counter's value by one.
|
long |
get()
Read this counter's current value.
|
void |
increment()
Increment this counter's value by one.
|
void |
set(long value)
Set this counter's value.
|
public long get()
adjust()
in the current transaction.StaleTransactionException
- if the transaction from which this instance
was read is no longer usableDeletedObjectException
- if the object from which this instance was read no longer existspublic void set(long value)
adjust()
in the current transaction.value
- new value for the counterStaleTransactionException
- if the transaction from which this instance
was read is no longer usableDeletedObjectException
- if the object from which this instance was read no longer existspublic void adjust(long offset)
offset
- amount to add to counterStaleTransactionException
- if the transaction from which this instance
was read is no longer usableDeletedObjectException
- if the object from which this instance was read no longer existspublic void increment()
StaleTransactionException
- if the transaction from which this instance
was read is no longer usableDeletedObjectException
- if the object from which this instance was read no longer existspublic void decrement()
StaleTransactionException
- if the transaction from which this instance
was read is no longer usableDeletedObjectException
- if the object from which this instance was read no longer existsCopyright © 2022. All rights reserved.