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>
fromGoogleSupplier(com.google.common.base.Supplier<T> supplier)
          Map from a google-collections Supplier.
static
<T> Supplier<T>
memoize(T source)
          A Supplier that always returns the supplied source.
static
<T> com.google.common.base.Supplier<T>
toGoogleSupplier(Supplier<T> supplier)
          Map to a google-collections Supplier.
 
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

toGoogleSupplier

public static <T> com.google.common.base.Supplier<T> toGoogleSupplier(Supplier<T> supplier)
Map to a google-collections Supplier.

Type Parameters:
T - type
Parameters:
function - the function to map
Returns:
the mapped function.

fromGoogleSupplier

public static <T> Supplier<T> fromGoogleSupplier(com.google.common.base.Supplier<T> supplier)
Map from a google-collections Supplier.

Type Parameters:
T - type
Parameters:
function - the function to map
Returns:
the mapped function.


Copyright © 2012 Atlassian. All Rights Reserved.