ExceptionCollector.java

net.minecraft.util.ExceptionCollector

信息

  • 全限定名:net.minecraft.util.ExceptionCollector
  • 类型:public class
  • 包:net.minecraft.util
  • 源码路径:src/main/java/net/minecraft/util/ExceptionCollector.java
  • 起始行号:L5
  • 职责:

    TODO

字段/常量

  • result
    • 类型: T
    • 修饰符: private
    • 源码定位: L6
    • 说明:

      TODO

内部类/嵌套类型

构造器

方法

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

public void add(T throwable) @ L8

  • 方法名:add
  • 源码定位:L8
  • 返回类型:void
  • 修饰符:public

参数:

  • throwable: T

说明:

TODO

public void throwIfPresent() @ L16

  • 方法名:throwIfPresent
  • 源码定位:L16
  • 返回类型:void
  • 修饰符:public

参数:

说明:

TODO

代码

public class ExceptionCollector<T extends Throwable> {
    private @Nullable T result;
 
    public void add(T throwable) {
        if (this.result == null) {
            this.result = throwable;
        } else {
            this.result.addSuppressed(throwable);
        }
    }
 
    public void throwIfPresent() throws T {
        if (this.result != null) {
            throw this.result;
        }
    }
}

引用的其他类