# Function

public interface **Function**

|---|---|---|
| Known Indirect Subclasses [UnaryOperator](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/function/UnaryOperator.html)\<T\> |---|---| | [UnaryOperator](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/function/UnaryOperator.html)\<T\> | Represents an operation on a single operand that produces a result of the same type as its operand. | |||

Represents a function that accepts one argument and produces a result.

This is a [functional interface](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/function/package-summary)
whose functional method is `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/function/Function.html#apply(T)`.

### Public Method Summary

|---|---|
| \<V\> [Function](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/function/Function.html)\<T, V\> | [andThen](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/function/Function.html#andThen(java.util.function.Function<?%20super%20R,%20?%20extends%20V>))([Function](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/function/Function.html)\<? super R, ? extends V\> after) Returns a composed function that first applies this function to its input, and then applies the `after` function to the result. |
| abstract R | [apply](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/function/Function.html#apply(T))(T t) Applies this function to the given argument. |
| \<V\> [Function](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/function/Function.html)\<V, R\> | [compose](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/function/Function.html#compose(java.util.function.Function<?%20super%20V,%20?%20extends%20T>))([Function](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/function/Function.html)\<? super V, ? extends T\> before) Returns a composed function that first applies the `before` function to its input, and then applies this function to the result. |
| static \<T\> [Function](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/function/Function.html)\<T, T\> | [identity](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/function/Function.html#identity())() Returns a function that always returns its input argument. |

## Public Methods

#### public [Function](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/function/Function.html)\<T, V\>
**andThen**
([Function](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/function/Function.html)\<? super R, ? extends V\> after)

Returns a composed function that first applies this function to
its input, and then applies the `after` function to the result.
If evaluation of either function throws an exception, it is relayed to
the caller of the composed function.

##### Parameters

| after | the function to apply after this function is applied |
|---|---|

##### Returns

- a composed function that first applies this function and then applies the `after` function

##### Throws

| [NullPointerException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/NullPointerException.html) | if after is null |
|---|---|

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/function/Function.html#compose(java.util.function.Function<?%20super%20V,%20?%20extends%20T>)`

#### public abstract R
**apply**
(T t)

Applies this function to the given argument.

##### Parameters

| t | the function argument |
|---|---|

##### Returns

- the function result

#### public [Function](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/function/Function.html)\<V, R\>
**compose**
([Function](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/function/Function.html)\<? super V, ? extends T\> before)

Returns a composed function that first applies the `before`
function to its input, and then applies this function to the result.
If evaluation of either function throws an exception, it is relayed to
the caller of the composed function.

##### Parameters

| before | the function to apply before this function is applied |
|---|---|

##### Returns

- a composed function that first applies the `before` function and then applies this function

##### Throws

| [NullPointerException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/NullPointerException.html) | if before is null |
|---|---|

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/java/util/function/Function.html#andThen(java.util.function.Function<?%20super%20R,%20?%20extends%20V>)`

#### public static [Function](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/function/Function.html)\<T, T\>
**identity**
()

Returns a function that always returns its input argument.

##### Returns

- a function that always returns its input argument