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

org.eclipse.esmf.functions.ThrowingConsumer Maven / Gradle / Ivy

There is a newer version: 2.9.5
Show newest version
/*
 * Copyright (c) 2024 Robert Bosch Manufacturing Solutions GmbH
 *
 * See the AUTHORS file(s) distributed with this work for additional
 * information regarding authorship.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at https://mozilla.org/MPL/2.0/.
 *
 * SPDX-License-Identifier: MPL-2.0
 */

package org.eclipse.esmf.functions;

import java.util.Objects;

/**
 * A Consumer similar to {@link java.util.function.Consumer} except a {@link Throwable} can be thrown
 *
 * @param  the type of the input to the function
 * @param  the type of Throwable that is thrown
 */
@FunctionalInterface
public interface ThrowingConsumer {
   void accept( T t ) throws E;

   default ThrowingConsumer andThen( final ThrowingConsumer after ) {
      Objects.requireNonNull( after );
      return ( final T t ) -> {
         accept( t );
         after.accept( t );
      };
   }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy