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 4-part arguments. 023 * 024 * @param <A> Argument 1. 025 * @param <B> Argument 2. 026 * @param <C> Argument 3. 027 * @param <D> Argument 4. 028 */ 029@FunctionalInterface 030public interface Consumer4<A,B,C,D> { 031 032 /** 033 * Performs this operation on the given arguments. 034 * 035 * @param a Argument 1. 036 * @param b Argument 2. 037 * @param c Argument 3. 038 * @param d Argument 4. 039 */ 040 void apply(A a, B b, C c, D d); 041 042 /** 043 * Returns a composed {@link Consumer} that performs, in sequence, this operation followed by the <c>after</c> operation. 044 * 045 * @param <V> The return type. 046 * @param after The operation to perform after this operation. 047 * @return A composed {@link Consumer} that performs in sequence this operation followed by the after operation. 048 */ 049 default <V> Consumer4<A,B,C,D> andThen(Consumer4<? super A,? super B,? super C, ? super D> after) { // NOSONAR - false positive on generics 050 return (A a, B b, C c, D d) -> { 051 apply(a, b, c, d); 052 after.apply(a, b, c, d); 053 }; 054 } 055}