Class CheckedProviders


  • public final class CheckedProviders
    extends Object
    Static utility methods for creating and working with instances of CheckedProvider.
    Since:
    4.2
    Author:
    eatnumber1@google.com (Russ Harmon)
    • Method Detail

      • of

        public static <T,​P extends CheckedProvider<? super T>> P of​(Class<P> providerType,
                                                                          @Nullable
                                                                          T instance)
        Returns a CheckedProvider which always provides instance.
        Parameters:
        providerType - the type of the CheckedProvider to return
        instance - the instance that should always be provided
        See Also:
        #of(TypeLiteral, T)
      • throwing

        public static <T,​P extends CheckedProvider<? super T>> P throwing​(com.google.inject.TypeLiteral<P> providerType,
                                                                                Class<? extends Throwable> throwable)
        Returns a CheckedProvider which always throws exceptions.

        This method uses the nullary (no argument) constructor of throwable to create a new instance of the given Throwable on each method invocation which is then thrown immediately.

        See #of(TypeLiteral, T) for more information.

        Parameters:
        providerType - the type of the CheckedProvider to return
        throwable - the type of the Throwable to throw
        See Also:
        #of(TypeLiteral, T)