public final class CheckedProviders extends Object
CheckedProvider
.Modifier and Type | Method and Description |
---|---|
static <T,P extends CheckedProvider<? super T>> |
of(Class<P> providerType,
T instance)
Returns a
CheckedProvider which always provides instance . |
static <T,P extends CheckedProvider<? super T>> |
of(TypeLiteral<P> providerType,
T instance)
Returns a
CheckedProvider which always provides instance . |
static <T,P extends CheckedProvider<? super T>> |
throwing(Class<P> providerType,
Class<? extends Throwable> throwable)
Returns a
CheckedProvider which always throws exceptions. |
static <T,P extends CheckedProvider<? super T>> |
throwing(TypeLiteral<P> providerType,
Class<? extends Throwable> throwable)
Returns a
CheckedProvider which always throws exceptions. |
public static <T,P extends CheckedProvider<? super T>> P of(TypeLiteral<P> providerType, @Nullable T instance)
CheckedProvider
which always provides instance
.
The provider type passed as providerType
must be an interface. Calls to methods
other than CheckedProvider.get()
will throw UnsupportedOperationException
.
providerType
- the type of the CheckedProvider
to returninstance
- the instance that should always be providedpublic static <T,P extends CheckedProvider<? super T>> P of(Class<P> providerType, @Nullable T instance)
CheckedProvider
which always provides instance
.providerType
- the type of the CheckedProvider
to returninstance
- the instance that should always be provided#of(TypeLiteral, T)
public static <T,P extends CheckedProvider<? super T>> P throwing(TypeLiteral<P> providerType, Class<? extends Throwable> throwable)
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.
providerType
- the type of the CheckedProvider
to returnthrowable
- the type of the Throwable
to throw#of(TypeLiteral, T)
public static <T,P extends CheckedProvider<? super T>> P throwing(Class<P> providerType, Class<? extends Throwable> throwable)
CheckedProvider
which always throws exceptions.providerType
- the type of the CheckedProvider
to returnthrowable
- the type of the Throwable
to throwthrowing(TypeLiteral, Class)
Copyright © 2006–2018 Google, Inc.. All rights reserved.