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

org.legendofdragoon.modloader.Latch Maven / Gradle / Ivy

There is a newer version: 3.0.4
Show newest version
package org.legendofdragoon.modloader;

import java.util.function.Supplier;

public class Latch implements Supplier {
  private final Supplier supplier;
  private T value;
  private boolean resolved;

  public Latch(final Supplier supplier) {
    this.supplier = supplier;
  }

  public void clear() {
    this.value = null;
    this.resolved = false;
  }

  @Override
  public T get() {
    if(!this.resolved) {
      this.value = this.supplier.get();
      this.resolved = true;
    }

    return this.value;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy