Class BundledUnicodeData.Lazy<T>

java.lang.Object
opennlp.tools.util.normalizer.BundledUnicodeData.Lazy<T>
Type Parameters:
T - The type of the data.
Enclosing class:
BundledUnicodeData

public static final class BundledUnicodeData.Lazy<T> extends Object
Holds data that is loaded on the first call to get(). A load that throws is not cached, so every call until one succeeds runs the loader and throws its exception.
  • Field Details

    • loader

      private final Supplier<T> loader
    • value

      private volatile T value
  • Constructor Details

    • Lazy

      public Lazy(Supplier<T> loader)
      Creates a holder that has not loaded yet.
      Parameters:
      loader - Loads the data. Must not be null and must not return null.
      Throws:
      IllegalArgumentException - Thrown if loader is null.
  • Method Details

    • get

      public T get()
      Returns the data, loading it on the first successful call.
      Returns:
      The loaded data.
      Throws:
      IllegalStateException - Thrown if the loader returns null.
      RuntimeException - Thrown as is if the loader fails; the next call loads again.