Class OptionalProviderFactory

Object
OptionalProviderFactory

public class OptionalProviderFactory extends Object
Utility functions to create Optional from nullable Providers.
Author:
Owen Feehan
  • Method Details

    • create

      public static <T> Optional<T> create(@Nullable Provider<T> provider) throws ProvisionFailedException
      Creates from a provider if non-null.
      Type Parameters:
      T - type of optional as created by the provider
      Parameters:
      provider - a provider or null (if it doesn't exist).
      Returns:
      the result of the create() option if provider is non-null, otherwise Optional.
      Throws:
      ProvisionFailedException - if this is thrown during the call to Provider.get().