RetryOptions.java

net.minecraft.gametest.framework.RetryOptions

信息

  • 全限定名:net.minecraft.gametest.framework.RetryOptions
  • 类型:public record
  • 包:net.minecraft.gametest.framework
  • 源码路径:src/main/java/net/minecraft/gametest/framework/RetryOptions.java
  • 起始行号:L3
  • 职责:

    TODO

字段/常量

  • NO_RETRIES
    • 类型: RetryOptions
    • 修饰符: private static final
    • 源码定位: L4
    • 说明:

      TODO

内部类/嵌套类型

构造器

方法

下面的方法块按源码顺序生成。

public static RetryOptions noRetries() @ L6

  • 方法名:noRetries
  • 源码定位:L6
  • 返回类型:RetryOptions
  • 修饰符:public static

参数:

说明:

TODO

public boolean unlimitedTries() @ L10

  • 方法名:unlimitedTries
  • 源码定位:L10
  • 返回类型:boolean
  • 修饰符:public

参数:

说明:

TODO

public boolean hasTriesLeft(int attempts, int successes) @ L14

  • 方法名:hasTriesLeft
  • 源码定位:L14
  • 返回类型:boolean
  • 修饰符:public

参数:

  • attempts: int
  • successes: int

说明:

TODO

public boolean hasRetries() @ L20

  • 方法名:hasRetries
  • 源码定位:L20
  • 返回类型:boolean
  • 修饰符:public

参数:

说明:

TODO

代码

public record RetryOptions(int numberOfTries, boolean haltOnFailure) {
    private static final RetryOptions NO_RETRIES = new RetryOptions(1, true);
 
    public static RetryOptions noRetries() {
        return NO_RETRIES;
    }
 
    public boolean unlimitedTries() {
        return this.numberOfTries < 1;
    }
 
    public boolean hasTriesLeft(int attempts, int successes) {
        boolean hasFailures = attempts != successes;
        boolean hasMoreAttempts = this.unlimitedTries() || attempts < this.numberOfTries;
        return hasMoreAttempts && (!hasFailures || !this.haltOnFailure);
    }
 
    public boolean hasRetries() {
        return this.numberOfTries != 1;
    }
}

引用的其他类