Interface ConfigurationResource<T>

All Superinterfaces:
AutoCloseable, Supplier<T>

public interface ConfigurationResource<T> extends Supplier<T>, AutoCloseable
Represents a configuration resource. If the resource is a AutoCloseable, then invoking AutoCloseable.close() on this resource will close the resource.
Author:
James R. Perkins
  • Method Summary

    Static Methods
    Modifier and Type
    Method
    Description
    static <T> ConfigurationResource<T>
    of(Supplier<T> supplier)
    Creates a configuration resource which lazily invokes the supplier.
    static <T> ConfigurationResource<T>
    of(T instance)
    Creates a configuration resource with the instance as a constant.

    Methods inherited from interface java.lang.AutoCloseable

    close

    Methods inherited from interface java.util.function.Supplier

    get
  • Method Details

    • of

      static <T> ConfigurationResource<T> of(Supplier<T> supplier)
      Creates a configuration resource which lazily invokes the supplier. Note that AutoCloseable.close() will only close the resource if Supplier.get() was first invoked to retrieve the value from the supplier.
      Parameters:
      supplier - the supplier used to create the configuration resource
      Returns:
      the configuration resource represented by a lazy instance
    • of

      static <T> ConfigurationResource<T> of(T instance)
      Creates a configuration resource with the instance as a constant. Note that if AutoCloseable.close() is invoked, Supplier.get() will return null.
      Parameters:
      instance - the constant instance
      Returns:
      the configuration resource represented by a constant instance