|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.atlassian.jira.util.Functions
public class Functions
Useful standard functions.
Constructor Summary | |
---|---|
Functions()
|
Method Summary | ||
---|---|---|
static
|
coerceToSuper()
Transform to a super class. |
|
static
|
downcast(Class<R> subclass)
Get a function that always the input downcast to the supplied class. |
|
static
|
identity()
Get a function that always returns the input. |
|
static
|
memoize(Function<T,R> function,
ConcurrentMap<T,R> map)
Memoizer maps an input to an output and always returns the mapped result rather than calling the wrapped function every time. |
|
static
|
toGoogleFunction(Function<T,R> function)
Map to a google-collections Function. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Functions()
Method Detail |
---|
public static <T,R> Function<T,R> memoize(Function<T,R> function, ConcurrentMap<T,R> map)
Note, once mapped the input and the result can only be externally removed. Also, if the supplied function returns nulls then no memoization will occur.
T
- the input type. MUST be immutable.R
- the result type.function
- for supplying the initial value that gets mappedmap
- for storing the key-value mappings
public static <T> Function<T,T> identity()
T
- the type of the input and the output for the function.
public static <T,R extends T> Function<T,R> downcast(Class<R> subclass)
T
- the type of the input and the output for the function.
public static <S,T extends S> Function<T,S> coerceToSuper()
Functions.<SuperClass, SubClass> coerceToSuper();
S
- the super class.T
- the sub class.public static <T,R> com.google.common.base.Function<T,R> toGoogleFunction(Function<T,R> function)
T
- input typeR
- output typefunction
- the function to map
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |