public final class CheckedProviders
extends java.lang.Object
CheckedProvider
.Modifier and Type | Method and Description |
---|---|
static <T,P extends CheckedProvider<? super T>> |
of(java.lang.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(java.lang.Class<P> providerType,
java.lang.Class<? extends java.lang.Throwable> throwable)
Returns a
CheckedProvider which always throws exceptions. |
static <T,P extends CheckedProvider<? super T>> |
throwing(TypeLiteral<P> providerType,
java.lang.Class<? extends java.lang.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(java.lang.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, java.lang.Class<? extends java.lang.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(java.lang.Class<P> providerType, java.lang.Class<? extends java.lang.Throwable> throwable)
CheckedProvider
which always throws exceptions.providerType
- the type of the CheckedProvider
to returnthrowable
- the type of the Throwable
to throwthrowing(TypeLiteral, Class)