Skip to content

IntegerSignal

class IntegerSignal
Extends: Signal<Integer>
Package: dev.joid.lib.signal.impl.primitive · Module: core · Source: IntegerSignal.java

Signal of an int with arithmetic that writes its result, for counters, scores and indexes.

It works like Signal; each operation reads the value, computes and writes the result, which notifies the listeners when it differs. The operations follow the Java int rules: they overflow without error and divide rounds toward zero. Called from another thread, an operation applies on the render thread to the value the signal holds then, so concurrent increments add up.

ReturnsSignatureSummary
IntegerSignal()Creates a signal whose value and default value are 0.
IntegerSignal(int value)Creates a signal whose value and default value are value.

ReturnsSignatureSummary
thisincrement() fluentAdds 1 to the value, then returns this signal.
thisdecrement() fluentRemoves 1 from the value, then returns this signal.
thisadd(int value) fluentAdds value to the value, then returns this signal.
thissubtract(int value) fluentRemoves value from the value, then returns this signal.
thismultiply(int value) fluentMultiplies the value by value, then returns this signal.
thisdivide(int value) fluentDivides the value by value, rounding toward zero, then returns this signal.
Inherited from Signal (12)

batch · silent · get · peek · isPresent · isWritable · toString · from · set · reset · removeOnChange · map

Inherited from Signal (1)

onChange

IntegerSignal()

Creates a signal whose value and default value are 0.

IntegerSignal(int value)

Creates a signal whose value and default value are value.

this increment() fluent

Adds 1 to the value, then returns this signal.

this decrement() fluent

Removes 1 from the value, then returns this signal.

this add(int value) fluent

Adds value to the value, then returns this signal.

this subtract(int value) fluent

Removes value from the value, then returns this signal.

this multiply(int value) fluent

Multiplies the value by value, then returns this signal.

this divide(int value) fluent

Throws:

  • IllegalArgumentException: The IntegerSignal of value … cannot be divided by 0, check the divisor before calling divide(…)

Divides the value by value, rounding toward zero, then returns this signal. A divisor of 0 throws an IllegalArgumentException at the call and leaves the value unchanged.


fluent returns the instance, typed for chaining · factory creates an instance · signal also accepts a value that follows signals, as a signal, an expression or a lambda (When does JOID compute this value again?) · hook called by JOID, override it · abstract you implement it · default interface method with a body · static called on the class · protected visible to subclasses

Report a problem with this page