001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.juneau.utils; 018 019import java.util.function.*; 020 021/** 022 * Functional interface for consumers of 2-part arguments. 023 * 024 * @param <A> Argument 1. 025 * @param <B> Argument 2. 026 */ 027@FunctionalInterface 028public interface Consumer2<A,B> { 029 030 /** 031 * Performs this operation on the given arguments. 032 * 033 * @param a Argument 1. 034 * @param b Argument 2. 035 */ 036 void apply(A a, B b); 037 038 /** 039 * Returns a composed {@link Consumer} that performs, in sequence, this operation followed by the <c>after</c> operation. 040 * 041 * @param <V> The return type. 042 * @param after The operation to perform after this operation. 043 * @return A composed {@link Consumer} that performs in sequence this operation followed by the after operation. 044 */ 045 default <V> Consumer2<A,B> andThen(Consumer2<? super A,? super B> after) { // NOSONAR - false positive on generics 046 return (A a, B b) -> { 047 apply(a, b); 048 after.apply(a, b); 049 }; 050 } 051}