Interface Sequential<E extends Sequential<E,​S,​U>,​S,​U>

  • Type Parameters:
    E - The implementing type e.g., Rational or Length (recursive type)
    S - The step type e.g., Rational
    U - The unit type of the step e.g., Void or LengthUnit
    All Superinterfaces:
    Comparable<E>

    public interface Sequential<E extends Sequential<E,​S,​U>,​S,​U>
    extends Comparable<E>
    Implement Sequential if the set of possible instances of your type are a sequence, whereby given an arbitrary instance of the type and some step or increment value, the next instance can be computed.
    • Method Detail

      • nextInSequence

        E nextInSequence​(S step,
                         U unit)
        Given a step and unit produces the next instance in the sequence. For instance, given a Length value of 1 meter, a step value of 5, and a unit of Centimeter, the next value in the sequence is 1.05 meters.
        Parameters:
        step - A value indicating the number of units separating this instance from the next one in the sequence.
        unit - Specifies the unit of the step for instance inch or month. Note if the unit type is Void, the unit value is insignificant and will have a null value.
        Returns:
        The next instance separated by step units from this instance.
      • nextNthInSequence

        E nextNthInSequence​(S step,
                            U unit,
                            int index)
        Given a step, unit, and index produce the next instance in the sequence. For instance, given a Length value of 1 meter, a step value of 5, a unit of Centimeter, and an index of 2, the next value in the sequence is 1.10 meters.
        Parameters:
        step - A value indicating the number of units separating this instance from the next one in the sequence.
        unit - Specifies the unit of the step for instance inch or month. Note if the unit type is Void, the unit value is insignificant and will have a null value.
        index - A offset in terms of step and unit, typically 1.
        Returns:
        The next instance separated by index * step * unit from this instance.
      • previousInSequence

        E previousInSequence​(S step,
                             U unit)
        Given a step and unit produces the previous instance in the sequence. For instance, given a Length value of 1 meter, a step value of 5, and a unit of Centimeter, the previous value in the sequence is 0.95 meters.
        Parameters:
        step - A value indicating the number of units separating this instance from the previous one in the sequence.
        unit - Specifies the unit of the step for instance inch or month. Note if the unit type is Void, the unit value is insignificant and will have a null value.
        Returns:
        The previous instance separated by step units from this instance.
      • previousNthInSequence

        E previousNthInSequence​(S step,
                                U unit,
                                int index)
        Given a step, unit, and index produce the previous instance in the sequence. For instance, given a Length value of 1 meter, a step value of 5, a unit of Centimeter, and an index of 2, the previous value in the sequence is 0.90 meters.
        Parameters:
        step - A value indicating the number of units separating this instance from the previous one in the sequence.
        unit - Specifies the unit of the step for instance inch or month. Note if the unit type is Void, the unit value is insignificant and will have a null value.
        index - A offset in terms of step and unit, typically 1.
        Returns:
        The previous instance separated by index * step * unit from this instance.