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

buckelieg.jdbc.fn.TryTriFunction Maven / Gradle / Ivy

The newest version!
/*
 * Copyright 2024- Anatoly Kutyakov
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package buckelieg.jdbc.fn;

import static java.util.Objects.requireNonNull;

/**
 * Three-argument function with returned result that might throw an exception
 * 
There is no requirement that a new or distinct result be returned each time the function is invoked *
This is a functional interface whose functional method is {@link #apply(Object, Object, Object)} * * @param first input argument type * @param second input argument type * @param third input argument type * @param result type * @param an exception type thrown */ @FunctionalInterface public interface TryTriFunction { /** * Represents a three-argument function which might throw an Exception * * @param input1 first argument * @param input2 second argument * @param input3 third argument * @return output * @throws E an exception */ O apply(I1 input1, I2 input2, I3 input3) throws E; /** * Returns a composed function that first applies this function to * its input, and then applies the {@code after} function to the result. * If evaluation of either function throws an exception, it is relayed to * the caller of the composed function. * * @param the type of output of the {@code after} function, and of the * composed function * @param after the function to apply after this function is applied * @return a composed function that first applies this function and then * applies the {@code after} function * @throws E an exception * @throws NullPointerException if after is null */ default TryTriFunction andThen(TryFunction after) throws E { if (null == after) throw new NullPointerException("after Function must be provided"); return (I1 input1, I2 input2, I3 input3) -> after.apply(apply(input1, input2, input3)); } /** * Returns reference of lambda expression * * @param tryTriFunction a function * @return lambda as {@link TryTriFunction} reference * @throws NullPointerException if tryTriFunction is null */ static TryTriFunction of(TryTriFunction tryTriFunction) { return requireNonNull(tryTriFunction, "Function must be provided"); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy