Interface Stepper<T>

Type Parameters:
T - 需要增加步进的对象
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface Stepper<T>
步进接口,此接口用于实现如何对一个对象按照指定步进增加步进 步进接口可以定义以下逻辑:
 1、步进规则,即对象如何做步进
 2、步进大小,通过实现此接口,在实现类中定义一个对象属性,可灵活定义步进大小
 3、限制range个数,通过实现此接口,在实现类中定义一个对象属性,可灵活定义limit,限制range个数
 
Since:
Java 17+
Author:
Kimi Liu
  • Method Summary

    Modifier and Type
    Method
    Description
    step(T current, T end, int index)
    增加步进 增加步进后的返回值如果为null则表示步进结束 用户需根据end参数自行定义边界,当达到边界时返回null表示结束,否则Range中边界对象无效,会导致无限循环
  • Method Details

    • step

      T step(T current, T end, int index)
      增加步进 增加步进后的返回值如果为null则表示步进结束 用户需根据end参数自行定义边界,当达到边界时返回null表示结束,否则Range中边界对象无效,会导致无限循环
      Parameters:
      current - 上一次增加步进后的基础对象
      end - 结束对象
      index - 当前索引(步进到第几个元素),从0开始计数
      Returns:
      增加步进后的对象