com.atlassian.util.concurrent
Class Suppliers

java.lang.Object
  extended by com.atlassian.util.concurrent.Suppliers

public final class Suppliers
extends java.lang.Object

Useful Supplier implementations.


Method Summary
static
<D,T> Supplier<T>
fromFunction(D input, Function<D,T> function)
          A Supplier that asks the argument function for the result using the input argument.
static
<T> Supplier<T>
memoize(T source)
          A Supplier that always returns the supplied source.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

memoize

public static <T> Supplier<T> memoize(T source)
A Supplier that always returns the supplied source.

Type Parameters:
T - the type
Parameters:
source - the object that is always returned.
Returns:
a supplier that always returns the supplied argument

fromFunction

public static <D,T> Supplier<T> fromFunction(D input,
                                             Function<D,T> function)
A Supplier that asks the argument function for the result using the input argument.

Type Parameters:
D - the input type
T - the result type
Parameters:
input - used as the argument when calling the function.
function - asked to get the result.
Returns:
the result


Copyright © 2011 Atlassian. All Rights Reserved.