Package org.osgi.util.function
Interface Supplier<T>
-
- Type Parameters:
T
- The type of the function output.
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@ConsumerType @FunctionalInterface public interface Supplier<T>
A function that produces a result.This is a functional interface and can be used as the assignment target for a lambda expression or method reference.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description static <T> java.util.function.Supplier<T>
asJavaSupplier(Supplier<T> wrapped)
Returns ajava.util.function.Supplier
which wraps the specifiedSupplier
and throws any thrown exceptions.static <T> java.util.function.Supplier<T>
asJavaSupplierOrElse(Supplier<T> wrapped, T orElse)
Returns ajava.util.function.Supplier
which wraps the specifiedSupplier
and the specified value.static <T> java.util.function.Supplier<T>
asJavaSupplierOrElseGet(Supplier<T> wrapped, java.util.function.Supplier<? extends T> orElseGet)
Returns ajava.util.function.Supplier
which wraps the specifiedSupplier
and the specifiedjava.util.function.Supplier
.static <T> Supplier<T>
asSupplier(java.util.function.Supplier<T> wrapped)
Returns aSupplier
which wraps the specifiedjava.util.function.Supplier
.T
get()
Returns a value.
-
-
-
Method Detail
-
get
T get() throws java.lang.Exception
Returns a value.- Returns:
- The output of this function.
- Throws:
java.lang.Exception
- An exception thrown by the method.
-
asJavaSupplier
static <T> java.util.function.Supplier<T> asJavaSupplier(Supplier<T> wrapped)
Returns ajava.util.function.Supplier
which wraps the specifiedSupplier
and throws any thrown exceptions.The returned
java.util.function.Supplier
will throw any exception thrown by the wrappedSupplier
.- Type Parameters:
T
- The type of the function output.- Parameters:
wrapped
- TheSupplier
to wrap. Must not benull
.- Returns:
- A
java.util.function.Supplier
which wraps the specifiedSupplier
.
-
asJavaSupplierOrElse
static <T> java.util.function.Supplier<T> asJavaSupplierOrElse(Supplier<T> wrapped, T orElse)
Returns ajava.util.function.Supplier
which wraps the specifiedSupplier
and the specified value.If the the specified
Supplier
throws anException
, the the specified value is returned.- Type Parameters:
T
- The type of the function output.- Parameters:
wrapped
- TheSupplier
to wrap. Must not benull
.orElse
- The value to return if the specifiedSupplier
throws anException
.- Returns:
- A
java.util.function.Supplier
which wraps the specifiedSupplier
and the specified value.
-
asJavaSupplierOrElseGet
static <T> java.util.function.Supplier<T> asJavaSupplierOrElseGet(Supplier<T> wrapped, java.util.function.Supplier<? extends T> orElseGet)
Returns ajava.util.function.Supplier
which wraps the specifiedSupplier
and the specifiedjava.util.function.Supplier
.If the the specified
Supplier
throws anException
, the value returned by the specifiedjava.util.function.Supplier
is returned.- Type Parameters:
T
- The type of the function output.- Parameters:
wrapped
- TheSupplier
to wrap. Must not benull
.orElseGet
- Thejava.util.function.Supplier
to call for a return value if the specifiedSupplier
throws anException
.- Returns:
- A
java.util.function.Supplier
which wraps the specifiedSupplier
and the specifiedjava.util.function.Supplier
.
-
asSupplier
static <T> Supplier<T> asSupplier(java.util.function.Supplier<T> wrapped)
Returns aSupplier
which wraps the specifiedjava.util.function.Supplier
.- Type Parameters:
T
- The type of the function output.- Parameters:
wrapped
- Thejava.util.function.Supplier
to wrap. Must not benull
.- Returns:
- A
Supplier
which wraps the specifiedjava.util.Supplier.Function
.
-
-