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

org.scijava.ops.engine.adapt.functional.ComputersToFunctionsViaFunction Maven / Gradle / Ivy

The newest version!
/*-
 * #%L
 * Java implementation of the SciJava Ops matching engine.
 * %%
 * Copyright (C) 2016 - 2024 SciJava developers.
 * %%
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 * 
 * 1. Redistributions of source code must retain the above copyright notice,
 *    this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright notice,
 *    this list of conditions and the following disclaimer in the documentation
 *    and/or other materials provided with the distribution.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 * #L%
 */
/*
 * This is autogenerated source code -- DO NOT EDIT. Instead, edit the
 * corresponding template in templates/ and rerun bin/generate.groovy.
 */

package org.scijava.ops.engine.adapt.functional;

import java.util.function.BiFunction;
import java.util.function.Function;

import org.scijava.function.Computers;
import org.scijava.function.Functions;
import org.scijava.ops.engine.BaseOpHints.Adaptation;
import org.scijava.ops.spi.OpDependency;
import org.scijava.ops.spi.Op;
import org.scijava.ops.spi.OpClass;

/**
 * Collection of adaptation Ops to convert {@link Computers} into
 * {@link Functions} with the use of a {@link Function} that creates the output
 * using the first input as a model.
 * 
 * @author Gabriel Selzer
 */
public class ComputersToFunctionsViaFunction {

	@OpClass(names = "engine.adapt")
	public static class Computer1ToFunction1ViaFunction
			implements Function, Function>,
			Op
		 {

		@OpDependency(name = "engine.create", hints={Adaptation.FORBIDDEN})
		Function creator;

		/**
		 * @param computer the Computer to adapt
		 * @return computer, adapted into a Function
		 */
		@Override
		public Function apply(Computers.Arity1 computer) {
			return (in) -> {
				O out = creator.apply(in);
				computer.compute(in, out);
				return out;
			};
		}

	}

	@OpClass(names = "engine.adapt")
	public static class Computer2ToFunction2ViaFunction
			implements Function, BiFunction>,
			Op
		 {

		@OpDependency(name = "engine.create", hints={Adaptation.FORBIDDEN})
		Function creator;

		/**
		 * @param computer the Computer to adapt
		 * @return computer, adapted into a Function
		 */
		@Override
		public BiFunction apply(Computers.Arity2 computer) {
			return (in1, in2) -> {
				O out = creator.apply(in1);
				computer.compute(in1, in2, out);
				return out;
			};
		}

	}

	@OpClass(names = "engine.adapt")
	public static class Computer3ToFunction3ViaFunction
			implements Function, Functions.Arity3>,
			Op
		 {

		@OpDependency(name = "engine.create", hints={Adaptation.FORBIDDEN})
		Function creator;

		/**
		 * @param computer the Computer to adapt
		 * @return computer, adapted into a Function
		 */
		@Override
		public Functions.Arity3 apply(Computers.Arity3 computer) {
			return (in1, in2, in3) -> {
				O out = creator.apply(in1);
				computer.compute(in1, in2, in3, out);
				return out;
			};
		}

	}

	@OpClass(names = "engine.adapt")
	public static class Computer4ToFunction4ViaFunction
			implements Function, Functions.Arity4>,
			Op
		 {

		@OpDependency(name = "engine.create", hints={Adaptation.FORBIDDEN})
		Function creator;

		/**
		 * @param computer the Computer to adapt
		 * @return computer, adapted into a Function
		 */
		@Override
		public Functions.Arity4 apply(Computers.Arity4 computer) {
			return (in1, in2, in3, in4) -> {
				O out = creator.apply(in1);
				computer.compute(in1, in2, in3, in4, out);
				return out;
			};
		}

	}

	@OpClass(names = "engine.adapt")
	public static class Computer5ToFunction5ViaFunction
			implements Function, Functions.Arity5>,
			Op
		 {

		@OpDependency(name = "engine.create", hints={Adaptation.FORBIDDEN})
		Function creator;

		/**
		 * @param computer the Computer to adapt
		 * @return computer, adapted into a Function
		 */
		@Override
		public Functions.Arity5 apply(Computers.Arity5 computer) {
			return (in1, in2, in3, in4, in5) -> {
				O out = creator.apply(in1);
				computer.compute(in1, in2, in3, in4, in5, out);
				return out;
			};
		}

	}

	@OpClass(names = "engine.adapt")
	public static class Computer6ToFunction6ViaFunction
			implements Function, Functions.Arity6>,
			Op
		 {

		@OpDependency(name = "engine.create", hints={Adaptation.FORBIDDEN})
		Function creator;

		/**
		 * @param computer the Computer to adapt
		 * @return computer, adapted into a Function
		 */
		@Override
		public Functions.Arity6 apply(Computers.Arity6 computer) {
			return (in1, in2, in3, in4, in5, in6) -> {
				O out = creator.apply(in1);
				computer.compute(in1, in2, in3, in4, in5, in6, out);
				return out;
			};
		}

	}

	@OpClass(names = "engine.adapt")
	public static class Computer7ToFunction7ViaFunction
			implements Function, Functions.Arity7>,
			Op
		 {

		@OpDependency(name = "engine.create", hints={Adaptation.FORBIDDEN})
		Function creator;

		/**
		 * @param computer the Computer to adapt
		 * @return computer, adapted into a Function
		 */
		@Override
		public Functions.Arity7 apply(Computers.Arity7 computer) {
			return (in1, in2, in3, in4, in5, in6, in7) -> {
				O out = creator.apply(in1);
				computer.compute(in1, in2, in3, in4, in5, in6, in7, out);
				return out;
			};
		}

	}

	@OpClass(names = "engine.adapt")
	public static class Computer8ToFunction8ViaFunction
			implements Function, Functions.Arity8>,
			Op
		 {

		@OpDependency(name = "engine.create", hints={Adaptation.FORBIDDEN})
		Function creator;

		/**
		 * @param computer the Computer to adapt
		 * @return computer, adapted into a Function
		 */
		@Override
		public Functions.Arity8 apply(Computers.Arity8 computer) {
			return (in1, in2, in3, in4, in5, in6, in7, in8) -> {
				O out = creator.apply(in1);
				computer.compute(in1, in2, in3, in4, in5, in6, in7, in8, out);
				return out;
			};
		}

	}

	@OpClass(names = "engine.adapt")
	public static class Computer9ToFunction9ViaFunction
			implements Function, Functions.Arity9>,
			Op
		 {

		@OpDependency(name = "engine.create", hints={Adaptation.FORBIDDEN})
		Function creator;

		/**
		 * @param computer the Computer to adapt
		 * @return computer, adapted into a Function
		 */
		@Override
		public Functions.Arity9 apply(Computers.Arity9 computer) {
			return (in1, in2, in3, in4, in5, in6, in7, in8, in9) -> {
				O out = creator.apply(in1);
				computer.compute(in1, in2, in3, in4, in5, in6, in7, in8, in9, out);
				return out;
			};
		}

	}

	@OpClass(names = "engine.adapt")
	public static class Computer10ToFunction10ViaFunction
			implements Function, Functions.Arity10>,
			Op
		 {

		@OpDependency(name = "engine.create", hints={Adaptation.FORBIDDEN})
		Function creator;

		/**
		 * @param computer the Computer to adapt
		 * @return computer, adapted into a Function
		 */
		@Override
		public Functions.Arity10 apply(Computers.Arity10 computer) {
			return (in1, in2, in3, in4, in5, in6, in7, in8, in9, in10) -> {
				O out = creator.apply(in1);
				computer.compute(in1, in2, in3, in4, in5, in6, in7, in8, in9, in10, out);
				return out;
			};
		}

	}

	@OpClass(names = "engine.adapt")
	public static class Computer11ToFunction11ViaFunction
			implements Function, Functions.Arity11>,
			Op
		 {

		@OpDependency(name = "engine.create", hints={Adaptation.FORBIDDEN})
		Function creator;

		/**
		 * @param computer the Computer to adapt
		 * @return computer, adapted into a Function
		 */
		@Override
		public Functions.Arity11 apply(Computers.Arity11 computer) {
			return (in1, in2, in3, in4, in5, in6, in7, in8, in9, in10, in11) -> {
				O out = creator.apply(in1);
				computer.compute(in1, in2, in3, in4, in5, in6, in7, in8, in9, in10, in11, out);
				return out;
			};
		}

	}

	@OpClass(names = "engine.adapt")
	public static class Computer12ToFunction12ViaFunction
			implements Function, Functions.Arity12>,
			Op
		 {

		@OpDependency(name = "engine.create", hints={Adaptation.FORBIDDEN})
		Function creator;

		/**
		 * @param computer the Computer to adapt
		 * @return computer, adapted into a Function
		 */
		@Override
		public Functions.Arity12 apply(Computers.Arity12 computer) {
			return (in1, in2, in3, in4, in5, in6, in7, in8, in9, in10, in11, in12) -> {
				O out = creator.apply(in1);
				computer.compute(in1, in2, in3, in4, in5, in6, in7, in8, in9, in10, in11, in12, out);
				return out;
			};
		}

	}

	@OpClass(names = "engine.adapt")
	public static class Computer13ToFunction13ViaFunction
			implements Function, Functions.Arity13>,
			Op
		 {

		@OpDependency(name = "engine.create", hints={Adaptation.FORBIDDEN})
		Function creator;

		/**
		 * @param computer the Computer to adapt
		 * @return computer, adapted into a Function
		 */
		@Override
		public Functions.Arity13 apply(Computers.Arity13 computer) {
			return (in1, in2, in3, in4, in5, in6, in7, in8, in9, in10, in11, in12, in13) -> {
				O out = creator.apply(in1);
				computer.compute(in1, in2, in3, in4, in5, in6, in7, in8, in9, in10, in11, in12, in13, out);
				return out;
			};
		}

	}

	@OpClass(names = "engine.adapt")
	public static class Computer14ToFunction14ViaFunction
			implements Function, Functions.Arity14>,
			Op
		 {

		@OpDependency(name = "engine.create", hints={Adaptation.FORBIDDEN})
		Function creator;

		/**
		 * @param computer the Computer to adapt
		 * @return computer, adapted into a Function
		 */
		@Override
		public Functions.Arity14 apply(Computers.Arity14 computer) {
			return (in1, in2, in3, in4, in5, in6, in7, in8, in9, in10, in11, in12, in13, in14) -> {
				O out = creator.apply(in1);
				computer.compute(in1, in2, in3, in4, in5, in6, in7, in8, in9, in10, in11, in12, in13, in14, out);
				return out;
			};
		}

	}

	@OpClass(names = "engine.adapt")
	public static class Computer15ToFunction15ViaFunction
			implements Function, Functions.Arity15>,
			Op
		 {

		@OpDependency(name = "engine.create", hints={Adaptation.FORBIDDEN})
		Function creator;

		/**
		 * @param computer the Computer to adapt
		 * @return computer, adapted into a Function
		 */
		@Override
		public Functions.Arity15 apply(Computers.Arity15 computer) {
			return (in1, in2, in3, in4, in5, in6, in7, in8, in9, in10, in11, in12, in13, in14, in15) -> {
				O out = creator.apply(in1);
				computer.compute(in1, in2, in3, in4, in5, in6, in7, in8, in9, in10, in11, in12, in13, in14, in15, out);
				return out;
			};
		}

	}

	@OpClass(names = "engine.adapt")
	public static class Computer16ToFunction16ViaFunction
			implements Function, Functions.Arity16>,
			Op
		 {

		@OpDependency(name = "engine.create", hints={Adaptation.FORBIDDEN})
		Function creator;

		/**
		 * @param computer the Computer to adapt
		 * @return computer, adapted into a Function
		 */
		@Override
		public Functions.Arity16 apply(Computers.Arity16 computer) {
			return (in1, in2, in3, in4, in5, in6, in7, in8, in9, in10, in11, in12, in13, in14, in15, in16) -> {
				O out = creator.apply(in1);
				computer.compute(in1, in2, in3, in4, in5, in6, in7, in8, in9, in10, in11, in12, in13, in14, in15, in16, out);
				return out;
			};
		}

	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy