Class CounterField


public class CounterField extends Field<Long>
Counter fields.

Counter fields have long values and can be adjusted concurrently by multiple transactions, typically without locking (depending on the underlying key/value store). Counter fields do not support indexing or change listeners.

Note: during @OnSchemaChange notifications, counter field values appear as Longs.

  • Method Details

    • getValue

      public Long getValue(Transaction tx, ObjId id)
      Description copied from class: Field
      Get the value of this field in the given object. Does not alter the schema of the object.
      Specified by:
      getValue in class Field<Long>
      Parameters:
      tx - transaction
      id - object id
      Returns:
      this field's value in the specified object
    • hasDefaultValue

      public boolean hasDefaultValue(Transaction tx, ObjId id)
      Description copied from class: Field
      Determine if this field in the specified object has its default value in the specified Transaction.
      Specified by:
      hasDefaultValue in class Field<Long>
      Parameters:
      tx - Transaction containing field state
      id - object ID
      Returns:
      true if this field is set to its initial default value in object id, otherwise false
    • visit

      public <R> R visit(FieldSwitch<R> target)
      Description copied from class: Field
      Apply visitor pattern.
      Specified by:
      visit in class Field<Long>
      Type Parameters:
      R - visitor return type
      Parameters:
      target - target to invoke
      Returns:
      return value from the method of target corresponding to this instance's type
    • toString

      public String toString()
      Specified by:
      toString in class SchemaItem