Skip to content

Commit

Permalink
Tweak javadoc further
Browse files Browse the repository at this point in the history
  • Loading branch information
daniellansun committed Jan 3, 2025
1 parent 3d97ab7 commit ec803b1
Showing 1 changed file with 44 additions and 9 deletions.
53 changes: 44 additions & 9 deletions src/main/java/groovy/util/function/FloatUnaryOperator.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,34 +19,69 @@
package groovy.util.function;

import java.util.Objects;
import java.util.function.UnaryOperator;

/**
* Represents an operation on a single {@code float}-valued operand that produces
* a {@code float}-valued result. This is the primitive type specialization of
* {@link UnaryOperator} for {@code float}.
* {@link java.util.function.UnaryOperator} for {@code float}.
*
* <p>This is a <a href="package-summary.html">functional interface</a>
* whose functional method is {@link #applyAsFloat(float)}.
*
* @see UnaryOperator
* @see java.util.function.UnaryOperator
* @since 5.0.0
*/
@FunctionalInterface
public interface FloatUnaryOperator {

/**
* Applies this operator to the given operand.
*
* @param operand the operand
* @return the operator result
*/
float applyAsFloat(float operand);

default FloatUnaryOperator andThen(FloatUnaryOperator after) {
Objects.requireNonNull(after);
return (float f) -> after.applyAsFloat(applyAsFloat(f));
}

/**
* Returns a composed operator that first applies the {@code before}
* operator to its input, and then applies this operator to the result.
* If evaluation of either operator throws an exception, it is relayed to
* the caller of the composed operator.
*
* @param before the operator to apply before this operator is applied
* @return a composed operator that first applies the {@code before}
* operator and then applies this operator
* @throws NullPointerException if before is null
*
* @see #andThen(FloatUnaryOperator)
*/
default FloatUnaryOperator compose(FloatUnaryOperator before) {
Objects.requireNonNull(before);
return (float f) -> applyAsFloat(before.applyAsFloat(f));
}

/**
* Returns a composed operator that first applies this operator to
* its input, and then applies the {@code after} operator to the result.
* If evaluation of either operator throws an exception, it is relayed to
* the caller of the composed operator.
*
* @param after the operator to apply after this operator is applied
* @return a composed operator that first applies this operator and then
* applies the {@code after} operator
* @throws NullPointerException if after is null
*
* @see #compose(FloatUnaryOperator)
*/
default FloatUnaryOperator andThen(FloatUnaryOperator after) {
Objects.requireNonNull(after);
return (float f) -> after.applyAsFloat(applyAsFloat(f));
}

/**
* Returns a unary operator that always returns its input argument.
*
* @return a unary operator that always returns its input argument
*/
static FloatUnaryOperator identity() {
return f -> f;
}
Expand Down

0 comments on commit ec803b1

Please sign in to comment.