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 2 objects. 019 * 020 * <p> 021 * Same as {@link BiFunction}. 022 * 023 * <p class='bjava'> 024 * Tuple2Function<A,B,R> <jv>x</jv> = (<jv>a</jv>,<jv>b</jv>) -> <jsm>doSomething</jsm>(<jv>a</jv>,<jv>b</jv>); 025 * 026 * R <jv>result</jv> = <jv>x</jv>.apply(<jv>xa</jv>,<jv>xb</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 <R> Result type. 035 */ 036@FunctionalInterface 037public interface Tuple2Function<A,B,R> { 038 039 @SuppressWarnings("javadoc") 040 R apply(A a, B b); 041 042 @SuppressWarnings("javadoc") 043 default <V> Tuple2Function<A,B,V> andThen(Function<? super R, ? extends V> after) { 044 return (A a, B b) -> after.apply(apply(a, b)); 045 } 046}