public class

Functions

extends Object
java.lang.Object
   ↳ com.atlassian.jira.util.Functions

Class Overview

Useful standard functions.

Summary

Public Constructors
Functions()
Public Methods
static <S, T extends S> Function<T, S> coerceToSuper()
Transform to a super class.
static <T, R extends T> Function<T, R> downcast(Class<R> subclass)
Get a function that always the input downcast to the supplied class.
static <T> Function<T, T> identity()
Get a function that always returns the input.
static <T, V> Visitor<T> mappedVisitor(Function<T, V> mappingFunction, Visitor<V> delegate)
Get a visitor that will apply the given function before delegating to another visitor.
static <T, R> Function<T, R> 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 <T, R> Function<T, R> toGoogleFunction(Function<T, R> function)
Map to a google-collections Function.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public Functions ()

Public Methods

public static Function<T, S> coerceToSuper ()

Transform to a super class. Usually needs to be called with explicit type parameters, eg: Functions.<SuperClass, SubClass> coerceToSuper();

public static Function<T, R> downcast (Class<R> subclass)

Get a function that always the input downcast to the supplied class.

Returns
  • the identity function.

public static Function<T, T> identity ()

Get a function that always returns the input.

Returns
  • the identity function.

public static Visitor<T> mappedVisitor (Function<T, V> mappingFunction, Visitor<V> delegate)

Get a visitor that will apply the given function before delegating to another visitor.

Parameters
mappingFunction the mapping function to apply
delegate the visitor to call with the function output values
Returns
  • a visitor that will accept input values for the function

public static Function<T, R> 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. Useful when the wrapped function is expensive to call.

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.

Parameters
function for supplying the initial value that gets mapped
map for storing the key-value mappings
Returns
  • a memoizing function.

public static Function<T, R> toGoogleFunction (Function<T, R> function)

Map to a google-collections Function.

Parameters
function the function to map
Returns
  • the mapped function.