001// ***************************************************************************************************************************
002// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.  See the NOTICE file *
003// * distributed with this work for additional information regarding copyright ownership.  The ASF licenses this file        *
004// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance            *
005// * with the License.  You may obtain a copy of the License at                                                              *
006// *                                                                                                                         *
007// *  http://www.apache.org/licenses/LICENSE-2.0                                                                             *
008// *                                                                                                                         *
009// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an  *
010// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the License for the        *
011// * specific language governing permissions and limitations under the License.                                              *
012// ***************************************************************************************************************************
013package org.apache.juneau.utils;
014
015import java.util.function.*;
016
017/**
018 * Allows you to perform a function against 4 objects.
019 *
020 * <p>
021 * Similar to {@link BiFunction} except for 4 parameters.
022 *
023 * <p class='bjava'>
024 *    Tuple4Function&lt;A,B,C,D,R&gt; <jv>x</jv> = (<jv>a</jv>,<jv>b</jv>,<jv>c</jv>,<jv>d</jv>) -&gt; <jsm>doSomething</jsm>(<jv>a</jv>,<jv>b</jv>,<jv>c</jv>,<jv>d</jv>);
025 *
026 *    R <jv>result</jv> = <jv>x</jv>.apply(<jv>xa</jv>,<jv>xb</jv>,<jv>xc</jv>,<jv>xd</jv>);
027 * </p>
028 *
029 * <h5 class='section'>See Also:</h5><ul>
030 * </ul>
031 *
032 * @param <A> Object 1 type.
033 * @param <B> Object 2 type.
034 * @param <C> Object 3 type.
035 * @param <D> Object 4 type.
036 * @param <R> Result type.
037 */
038@FunctionalInterface
039public interface Tuple4Function<A,B,C,D,R> {
040
041   @SuppressWarnings("javadoc")
042   R apply(A a, B b, C c, D d);
043
044   @SuppressWarnings("javadoc")
045   default <V> Tuple4Function<A,B,C,D,V> andThen(Function<? super R, ? extends V> after) {
046      return (A a, B b, C c, D d) -> after.apply(apply(a, b, c, d));
047   }
048}