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

com.softicar.platform.common.core.interfaces.NullaryVoidFunctionList 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.ArrayList;
import java.util.Collection;
import java.util.Objects;

/**
 * Aggregates multiple {@link INullaryVoidFunction} objects into a list, that
 * itself implements {@link INullaryVoidFunction}.
 *
 * @author Oliver Richers
 */
public class NullaryVoidFunctionList implements INullaryVoidFunction {

	private final Collection functions;

	public NullaryVoidFunctionList() {

		this.functions = new ArrayList<>();
	}

	/**
	 * Calls all contained {@link INullaryVoidFunction} objects in the order
	 * that they were added.
	 */
	@Override
	public void apply() {

		for (var function: functions) {
			function.apply();
		}
	}

	public NullaryVoidFunctionList add(INullaryVoidFunction function) {

		functions.add(Objects.requireNonNull(function));
		return this;
	}

	public NullaryVoidFunctionList addAll(NullaryVoidFunctionList other) {

		functions.addAll(other.functions);
		return this;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy