Client and backend. This class is shared: the same code is compiled into your app and into your server, so everything on this page works in both.

@FunctionalInterface

public interface Function<T, R>

Known subtypesUnaryOperator

A function of one argument.

Type parameters

<T>
the input type
<R>
the result type

Methods

public abstract R apply(T t)Applies this function.
public default <V> Function<V, R> compose(Function<? super V, ? extends T> before)before, then this function on its result.
public default <V> Function<T, V> andThen(Function<? super R, ? extends V> after)This function, then after on its result.
public static <T> Function<T, T> identity()The function that answers its argument.

Method details

apply

public abstract R apply(T t)
Applies this function.

Parameters

t T
the input

Returns

the result

compose

public default <V> Function<V, R> compose(Function<? super V, ? extends T> before)
before, then this function on its result.

Parameters

before Function<? super V, ? extends T>
the function applied first
<V>
the input type of before

Returns

the composed function

andThen

public default <V> Function<T, V> andThen(Function<? super R, ? extends V> after)
This function, then after on its result.

Parameters

after Function<? super R, ? extends V>
the function applied next
<V>
the result type of after

Returns

the composed function

identity

public static <T> Function<T, T> identity()
The function that answers its argument.

Parameters

<T>
the type

Returns

the identity function