Package ste.lloop
Class NumericSeries
java.lang.Object
ste.lloop.NumericSeries
A numeric loop that can be configured with a starting and ending value.
This class is not meant to be instantiated directly. Use Loop.on() to start building a
numeric loop.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
-
Field Details
-
from
protected int fromThe starting value of the loop (inclusive). -
to
The ending value of the loop (inclusive). -
step
protected int stepThe step of the loop.
-
-
Constructor Details
-
NumericSeries
public NumericSeries()Constructs a newNumericSeriesinstance.
-
-
Method Details
-
from
Sets the starting value of the loop (inclusive).- Parameters:
from- the starting value- Returns:
- this
NumericSeriesinstance
-
to
Sets the ending value of the loop (inclusive).- Parameters:
to- the ending value- Returns:
- this
NumericSeriesinstance
-
step
Sets the step of the loop. The sign of the step determines the direction of the loop.If the step is positive, the loop will go from
fromtoto. If the step is negative, the loop will go fromtotofrom.The absolute value of the step is used as the increment. If the step is zero, the loop will not execute.
- Parameters:
step- the step value- Returns:
- this
NumericSeriesinstance
-
loop
Executes the given consumer for each value in the loop. Iffromandtoare equal, the loop will not execute.- Parameters:
consumer- the consumer to execute for each value
-