Class SegmentAllocator.Segment

java.lang.Object
cloud.opencode.base.id.segment.SegmentAllocator.Segment
Enclosing interface:
SegmentAllocator

public static final class SegmentAllocator.Segment extends Object
Segment definition 号段定义
Since:
JDK 25, opencode-base-id V1.0.0
Author:
Leon Soo www.LeonSoo.com
  • Constructor Summary

    Constructors
    Constructor
    Description
    Segment(long start, long end, int step)
    Creates a segment 创建号段
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    end()
    Gets the end value 获取结束值
    long
    Gets the current value (same as start) 获取当前值(与start相同)
    long
    Gets the maximum value (same as end) 获取最大值(与end相同)
    long
    Gets the remaining count 获取剩余数量
    long
    Gets the start value 获取起始值
    int
    Gets the step size 获取步长
     

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Segment

      public Segment(long start, long end, int step)
      Creates a segment 创建号段
      Parameters:
      start - the start value (inclusive) | 起始值(包含)
      end - the end value (exclusive) | 结束值(不包含)
      step - the step size | 步长
      Throws:
      IllegalArgumentException - if start is negative, end < start, or step <= 0
  • Method Details

    • start

      public long start()
      Gets the start value 获取起始值
      Returns:
      start value | 起始值
    • end

      public long end()
      Gets the end value 获取结束值
      Returns:
      end value | 结束值
    • step

      public int step()
      Gets the step size 获取步长
      Returns:
      step size | 步长
    • getMaxValue

      public long getMaxValue()
      Gets the maximum value (same as end) 获取最大值(与end相同)
      Returns:
      max value | 最大值
    • getCurrentValue

      public long getCurrentValue()
      Gets the current value (same as start) 获取当前值(与start相同)
      Returns:
      current value | 当前值
    • remaining

      public long remaining()
      Gets the remaining count 获取剩余数量
      Returns:
      remaining count | 剩余数量
    • toString

      public String toString()
      Overrides:
      toString in class Object