Stay organized with collections
Save and categorize content based on your preferences.
UnaryOperator
public
interface
UnaryOperator
implements
Function<T, T>
java.util.function.UnaryOperator<T>
|
Represents an operation on a single operand that produces a result of the
same type as its operand. This is a specialization of Function
for
the case where the operand and result are of the same type.
This is a functional interface
whose functional method is Function.apply(java.lang.Object)
.
Summary
Public methods |
static
<T>
UnaryOperator<T>
|
identity()
Returns a unary operator that always returns its input argument.
|
Inherited methods |
From interface
java.util.function.Function
default
<V>
Function<T, V>
|
andThen(Function<? 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
T
|
apply(T t)
Applies this function to the given argument.
|
default
<V>
Function<V, T>
|
compose(Function<? 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<T, T>
|
identity()
Returns a function that always returns its input argument.
|
|
Public methods
identity
public static UnaryOperator<T> identity ()
Returns a unary operator that always returns its input argument.
Returns |
UnaryOperator<T> |
a unary operator that always returns its input argument |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[null,null,["Last updated 2025-02-10 UTC."],[],[],null,["# UnaryOperator\n\nAdded in [API level 24](/guide/topics/manifest/uses-sdk-element#ApiLevels) \nSummary: [Methods](#pubmethods) \\| [Inherited Methods](#inhmethods) \n\nUnaryOperator\n=============\n\n\n`\npublic\n\n\ninterface\nUnaryOperator\n`\n\n\n`\n\n\nimplements\n\n`[Function](/reference/java/util/function/Function)`\u003cT, T\u003e\n\n\n`\n\n|---------------------------------------|\n| java.util.function.UnaryOperator\\\u003cT\\\u003e |\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\nRepresents an operation on a single operand that produces a result of the\nsame type as its operand. This is a specialization of `Function` for\nthe case where the operand and result are of the same type.\n\nThis is a [functional interface](/reference/java/util/function/package-summary)\nwhose functional method is [Function.apply(java.lang.Object)](/reference/java/util/function/Function#apply(T)). \n**See also:**\n\n- [Function](/reference/java/util/function/Function)\n\nSummary\n-------\n\n| ### Public methods ||\n|---------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------|\n| ` static \u003cT\u003e `[UnaryOperator](/reference/java/util/function/UnaryOperator)`\u003cT\u003e` | ` `[identity](/reference/java/util/function/UnaryOperator#identity())`() ` Returns a unary operator that always returns its input argument. |\n\n| ### Inherited methods |\n|-----------------------|---|\n| From interface ` `[java.util.function.Function](/reference/java/util/function/Function)` ` |---------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` default \u003cV\u003e `[Function](/reference/java/util/function/Function)`\u003cT, V\u003e` | ` `[andThen](/reference/java/util/function/Function#andThen(java.util.function.Function\u003c?%20super%20R,?%20extends%20V\u003e))`(`[Function](/reference/java/util/function/Function)`\u003c? super R, ? extends V\u003e after) ` Returns a composed function that first applies this function to its input, and then applies the `after` function to the result. | | ` abstract T` | ` `[apply](/reference/java/util/function/Function#apply(T))`(T t) ` Applies this function to the given argument. | | ` default \u003cV\u003e `[Function](/reference/java/util/function/Function)`\u003cV, T\u003e` | ` `[compose](/reference/java/util/function/Function#compose(java.util.function.Function\u003c?%20super%20V,?%20extends%20T\u003e))`(`[Function](/reference/java/util/function/Function)`\u003c? super V, ? extends T\u003e before) ` Returns a composed function that first applies the `before` function to its input, and then applies this function to the result. | | ` static \u003cT\u003e `[Function](/reference/java/util/function/Function)`\u003cT, T\u003e` | ` `[identity](/reference/java/util/function/Function#identity())`() ` Returns a function that always returns its input argument. | ||\n\nPublic methods\n--------------\n\n### identity\n\nAdded in [API level 24](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic static UnaryOperator\u003cT\u003e identity ()\n```\n\nReturns a unary operator that always returns its input argument.\n\n\u003cbr /\u003e\n\n| Returns ||\n|-------------------------------------------------------------------|----------------------------------------------------------------|\n| [UnaryOperator](/reference/java/util/function/UnaryOperator)`\u003cT\u003e` | a unary operator that always returns its input argument \u003cbr /\u003e |"]]