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.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Lazy(Supplier<T> loader)
    Creates a holder that has not loaded yet.
  • Method Summary

    Modifier and Type
    Method
    Description
    get()
    Returns the data, loading it on the first successful call.

    Methods inherited from class Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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.