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

ru.progrm_jarvis.javacommons.util.function.ByteBinaryOperator Maven / Gradle / Ivy

package ru.progrm_jarvis.javacommons.util.function;

import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;

import java.util.function.BinaryOperator;
import java.util.function.UnaryOperator;

/**
 * Represents an operation on a single {@code byte} operand that produces a {@code byte} result.
 * This is the primitive type specialization of {@link UnaryOperator} for {@code byte}.
 *
 * @see UnaryOperator non-primitive generic equivalent
 */
@FunctionalInterface
public interface ByteBinaryOperator extends BinaryOperator<@NotNull Byte> {

    /**
    * Applies this operator to the given operands.
    *
    * @param left the first operand
    * @param right the second operand
    * @return result of applying this operation to the operands
    */
    byte applyAsByte(byte left, byte right);

    @Override
    @Contract("null, _ -> fail; _, null -> fail; _ -> _")
    default @NotNull Byte apply(final @NotNull Byte left, final @NotNull Byte right) {
        // note: there is no need for explicit null-checkins as it will be done when unwrapping the values
        return applyAsByte(left, right);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy