All Downloads are FREE. Search and download functionalities are using the official Maven repository.

.0.9.1.source-code.FloatUnaryOperator Maven / Gradle / Ivy

Go to download

Supplementary utilities for classes that belong to java.util, or are considered essential as to justify existence in java.util.

The newest version!
/* Copyright (c) 2019 LibJ
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * You should have received a copy of The MIT License (MIT) along with this
 * program. If not, see .
 */

package org.libj.util.function;

import java.util.Objects;

import javax.annotation.Generated;

/**
 * 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 java.util.function.UnaryOperator} for {@code float}.
 *
 * @see java.util.function.UnaryOperator
 */
@FunctionalInterface
@Generated(value="org.openjax.codegen.template.Templates", date="2024-02-27T13:50:20.763")
public interface FloatUnaryOperator {
  /**
   * Applies this operator to the given operand.
   *
   * @param operand The operand.
   * @return The operator result.
   */
  float applyAsFloat(float operand);

  /**
   * 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 {@code before} is null.
   * @see #andThen(FloatUnaryOperator)
   */
  default FloatUnaryOperator compose(FloatUnaryOperator before) {
    Objects.requireNonNull(before);
    return (float v) -> applyAsFloat(before.applyAsFloat(v));
  }

  /**
   * 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 {@code after} is null.
   * @see #compose(FloatUnaryOperator)
   */
  default FloatUnaryOperator andThen(FloatUnaryOperator after) {
    Objects.requireNonNull(after);
    return (float t) -> after.applyAsFloat(applyAsFloat(t));
  }

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy