All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.aya.util.reporter.DelayedReporter Maven / Gradle / Ivy

There is a newer version: 0.34.0
Show newest version
// Copyright (c) 2020-2022 Yinsen (Tesla) Zhang.
// Use of this source code is governed by the MIT license that can be found in the LICENSE.md file.
package org.aya.util.reporter;

import kala.collection.mutable.MutableList;
import org.jetbrains.annotations.NotNull;

public record DelayedReporter(
  @NotNull Reporter delegated,
  @NotNull MutableList problems
) implements CollectingReporter, AutoCloseable {
  public DelayedReporter(@NotNull Reporter delegated) {
    this(delegated, MutableList.create());
  }

  @Override public void report(@NotNull Problem problem) {
    problems.append(problem);
  }

  public void reportNow() {
    problems.forEach(this.delegated::report);
    problems.clear();
  }

  @Override public void close() {
    reportNow();
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy