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

com.softicar.platform.common.core.interfaces.BiConsumers Maven / Gradle / Ivy

Go to download

The SoftiCAR Platform is a lightweight, Java-based library to create interactive business web applications.

There is a newer version: 50.0.0
Show newest version
package com.softicar.platform.common.core.interfaces;

import java.util.Objects;
import java.util.function.BiConsumer;
import java.util.function.Consumer;

/**
 * Utility methods for the {@link BiConsumer} interface.
 *
 * @author Oliver Richers
 */
public class BiConsumers {

	private static final BiConsumer NO_OPERATION = (x, y) -> {
		// nothing to do by design
	};

	@SuppressWarnings("unchecked")
	public static  BiConsumer noOperation() {

		return (BiConsumer) NO_OPERATION;
	}

	/**
	 * Binds the given argument as the first parameter of the given
	 * {@link BiConsumer}.
	 *
	 * @param consumer
	 *            the {@link BiConsumer} (never null)
	 * @param first
	 *            the argument for the first parameter (may be null)
	 * @return the new {@link Consumer} (never null)
	 */
	public static  Consumer bindFirst(BiConsumer consumer, T first) {

		Objects.requireNonNull(consumer);
		return second -> consumer.accept(first, second);
	}

	/**
	 * Binds the given argument as the second parameter of the given
	 * {@link BiConsumer}.
	 *
	 * @param consumer
	 *            the {@link BiConsumer} (never null)
	 * @param second
	 *            the argument for the first parameter (may be null)
	 * @return the new {@link Consumer} (never null)
	 */
	public static  Consumer bindSecond(BiConsumer consumer, S second) {

		Objects.requireNonNull(consumer);
		return first -> consumer.accept(first, second);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy