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

xyz.funjava.functional.validation.Validation Maven / Gradle / Ivy

Go to download

This is a typesafe validation library with an aim on composition, reuse and safety. Tools are provided to create, compose or enrich validator while maintaining type safety.

The newest version!
/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package xyz.funjava.functional.validation;

import xyz.funjava.functional.CheckedFunction10;
import xyz.funjava.functional.CheckedFunction11;
import xyz.funjava.functional.CheckedFunction12;
import xyz.funjava.functional.CheckedFunction13;
import xyz.funjava.functional.CheckedFunction14;
import xyz.funjava.functional.CheckedFunction15;
import xyz.funjava.functional.CheckedFunction16;
import xyz.funjava.functional.CheckedFunction17;
import xyz.funjava.functional.CheckedFunction18;
import xyz.funjava.functional.CheckedFunction19;
import xyz.funjava.functional.CheckedFunction2;
import xyz.funjava.functional.CheckedFunction20;
import xyz.funjava.functional.CheckedFunction21;
import xyz.funjava.functional.CheckedFunction22;
import xyz.funjava.functional.CheckedFunction23;
import xyz.funjava.functional.CheckedFunction24;
import xyz.funjava.functional.CheckedFunction25;
import xyz.funjava.functional.CheckedFunction26;
import xyz.funjava.functional.CheckedFunction3;
import xyz.funjava.functional.CheckedFunction4;
import xyz.funjava.functional.CheckedFunction5;
import xyz.funjava.functional.CheckedFunction6;
import xyz.funjava.functional.CheckedFunction7;
import xyz.funjava.functional.CheckedFunction8;
import xyz.funjava.functional.CheckedFunction9;
import xyz.funjava.functional.Function10;
import xyz.funjava.functional.Function11;
import xyz.funjava.functional.Function12;
import xyz.funjava.functional.Function13;
import xyz.funjava.functional.Function14;
import xyz.funjava.functional.Function15;
import xyz.funjava.functional.Function16;
import xyz.funjava.functional.Function17;
import xyz.funjava.functional.Function18;
import xyz.funjava.functional.Function19;
import xyz.funjava.functional.Function2;
import xyz.funjava.functional.Function20;
import xyz.funjava.functional.Function21;
import xyz.funjava.functional.Function22;
import xyz.funjava.functional.Function23;
import xyz.funjava.functional.Function24;
import xyz.funjava.functional.Function25;
import xyz.funjava.functional.Function26;
import xyz.funjava.functional.Function3;
import xyz.funjava.functional.Function4;
import xyz.funjava.functional.Function5;
import xyz.funjava.functional.Function6;
import xyz.funjava.functional.Function7;
import xyz.funjava.functional.Function8;
import xyz.funjava.functional.Function9;
import xyz.funjava.functional.higherkinded.applicative.Applicative;
import xyz.funjava.functional.higherkinded.monoid.Monoid;

import java.util.function.Function;

/**
 * @author Carlos Sierra Andrés
 */
public interface Validation>
	extends Applicative {

	public boolean isSuccess();

	public T get();

	public F failures();

	public  Validation map(Function fun);

	public > Validation mapFailures(
		Function fun);

	public  Validation flatMap(Function> fun);

	@Override
	public  Validation applyTo(
		Applicative> fun);

	default  Validation pure(S s) {
		return new Success<>(s);
	}

	class Success> implements Validation {

		private final T _t;

		public Success(T t) {
			_t = t;
		}

		public  Validation map(Function fun) {
			return new Success<>(fun.apply(_t));
		}

		@Override
		public > Validation mapFailures(
			Function fun) {

			return (Validation)this;
		}

		@Override
		public  Validation applyTo(
			Applicative> fun) {

			return ((Validation, F>)fun).map(f -> f.apply(_t));
		}

		@Override
		public String toString() {
			return "Success {" + _t + '}';
		}

		public  Validation flatMap(Function> fun) {
			return fun.apply(_t);
		}

		@Override
		public boolean isSuccess() {
			return true;
		}

		@Override
		public T get() {
			return _t;
		}

		@Override
		public F failures() {
			throw new IllegalStateException();
		}

		@Override
		public boolean equals(Object o) {
			if (this == o) return true;
			if (o == null || getClass() != o.getClass()) return false;

			Success success = (Success) o;

			return _t.equals(success._t);
		}

		@Override
		public int hashCode() {
			return _t.hashCode();
		}

	}

	class Failure> implements Validation {

		private F _failure;

		public Failure(F failure) {
			_failure = failure;
		}

		@Override
		public  Validation map(
			Function fun) {

			return (Validation)this;
		}

		@Override
		public > Validation mapFailures(
			Function fun) {

			return new Failure<>(fun.apply(_failure));
		}

		@Override
		public  Validation applyTo(
			Applicative> ap) {

			if (ap instanceof Failure) {
				return new Failure<>((F)_failure.mappend(((Failure) ap)._failure));
			}

			else {
				return (Validation)this;
			}
		}

		@Override
		public String toString() {
			return "Failure {" + "Reasons: " + _failure.toString() + '}';
		}

		@Override
		public  Validation flatMap(
			Function> fun) {

			return (Validation)this;
		}

		@Override
		public boolean isSuccess() {
			return false;
		}

		@Override
		public T get() {
			throw new IllegalStateException();
		}

		@Override
		public F failures() {
			return _failure;
		}

		@Override
		public boolean equals(Object o) {
			if (this == o) return true;
			if (o == null || getClass() != o.getClass()) return false;

			Failure failure = (Failure) o;

			return _failure.equals(failure._failure);
		}

		@Override
		public int hashCode() {
			return _failure.hashCode();
		}

	}

	static > Validation just(T t) {
		return new Success<>(t);
	}

	public static > Function2> wrap(CheckedFunction2 fun, Function error) {
		return (a, b) -> {
			try {
				return new Success<>(fun.apply(a, b));
			}
			catch (Exception ex) {
				return new Failure<>(error.apply(ex));
			}
		};
	}

	public static  Function2 ignore(CheckedFunction2 fun) {
		return (a, b) -> {
			try {
				return fun.apply(a, b);
			}
			catch (Exception ex) {
				throw new RuntimeException(ex);
			}
		};
	}

	public static > Validation apply(Function2 fun, Validation a, Validation b) {
		return (Validation)Applicative.apply(fun, a, b);
	}

	public static > Validation apply(Function3 fun, Validation a, Validation b, Validation c) {
		return (Validation)Applicative.apply(fun, a, b, c);
	}

	public static > Validation apply(Function4 fun, Validation a, Validation b, Validation c, Validation d) {
		return (Validation)Applicative.apply(fun, a, b, c, d);
	}

	public static > Validation apply(Function5 fun, Validation a, Validation b, Validation c, Validation d, Validation e) {
		return (Validation)Applicative.apply(fun, a, b, c, d, e);
	}

	public static > Validation apply(Function6 fun, Validation a, Validation b, Validation c, Validation d, Validation e, Validation f) {
		return (Validation)Applicative.apply(fun, a, b, c, d, e, f);
	}

	public static > Validation apply(Function7 fun, Validation a, Validation b, Validation c, Validation d, Validation e, Validation f, Validation g) {
		return (Validation)Applicative.apply(fun, a, b, c, d, e, f, g);
	}

	public static > Validation apply(Function8 fun, Validation a, Validation b, Validation c, Validation d, Validation e, Validation f, Validation g, Validation h) {
		return (Validation)Applicative.apply(fun, a, b, c, d, e, f, g, h);
	}

	public static > Validation apply(Function9 fun, Validation a, Validation b, Validation c, Validation d, Validation e, Validation f, Validation g, Validation h, Validation i) {
		return (Validation)Applicative.apply(fun, a, b, c, d, e, f, g, h, i);
	}

	public static > Validation apply(Function10 fun, Validation a, Validation b, Validation c, Validation d, Validation e, Validation f, Validation g, Validation h, Validation i, Validation j) {
		return (Validation)Applicative.apply(fun, a, b, c, d, e, f, g, h, i, j);
	}

	public static > Validation apply(Function11 fun, Validation a, Validation b, Validation c, Validation d, Validation e, Validation f, Validation g, Validation h, Validation i, Validation j, Validation k) {
		return (Validation)Applicative.apply(fun, a, b, c, d, e, f, g, h, i, j, k);
	}

	public static > Validation apply(Function12 fun, Validation a, Validation b, Validation c, Validation d, Validation e, Validation f, Validation g, Validation h, Validation i, Validation j, Validation k, Validation l) {
		return (Validation)Applicative.apply(fun, a, b, c, d, e, f, g, h, i, j, k, l);
	}

	public static > Validation apply(Function13 fun, Validation a, Validation b, Validation c, Validation d, Validation e, Validation f, Validation g, Validation h, Validation i, Validation j, Validation k, Validation l, Validation m) {
		return (Validation)Applicative.apply(fun, a, b, c, d, e, f, g, h, i, j, k, l, m);
	}

	public static > Validation apply(Function14 fun, Validation a, Validation b, Validation c, Validation d, Validation e, Validation f, Validation g, Validation h, Validation i, Validation j, Validation k, Validation l, Validation m, Validation n) {
		return (Validation)Applicative.apply(fun, a, b, c, d, e, f, g, h, i, j, k, l, m, n);
	}

	public static > Validation apply(Function15 fun, Validation a, Validation b, Validation c, Validation d, Validation e, Validation f, Validation g, Validation h, Validation i, Validation j, Validation k, Validation l, Validation m, Validation n, Validation o) {
		return (Validation)Applicative.apply(fun, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o);
	}

	public static > Validation apply(Function16 fun, Validation a, Validation b, Validation c, Validation d, Validation e, Validation f, Validation g, Validation h, Validation i, Validation j, Validation k, Validation l, Validation m, Validation n, Validation o, Validation p) {
		return (Validation)Applicative.apply(fun, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p);
	}

	public static > Validation apply(Function17 fun, Validation a, Validation b, Validation c, Validation d, Validation e, Validation f, Validation g, Validation h, Validation i, Validation j, Validation k, Validation l, Validation m, Validation n, Validation o, Validation p, Validation q) {
		return (Validation)Applicative.apply(fun, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q);
	}

	public static > Validation apply(Function18 fun, Validation a, Validation b, Validation c, Validation d, Validation e, Validation f, Validation g, Validation h, Validation i, Validation j, Validation k, Validation l, Validation m, Validation n, Validation o, Validation p, Validation q, Validation r) {
		return (Validation)Applicative.apply(fun, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r);
	}

	public static > Validation apply(Function19 fun, Validation a, Validation b, Validation c, Validation d, Validation e, Validation f, Validation g, Validation h, Validation i, Validation j, Validation k, Validation l, Validation m, Validation n, Validation o, Validation p, Validation q, Validation r, Validation s) {
		return (Validation)Applicative.apply(fun, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s);
	}

	public static > Validation apply(Function20 fun, Validation a, Validation b, Validation c, Validation d, Validation e, Validation f, Validation g, Validation h, Validation i, Validation j, Validation k, Validation l, Validation m, Validation n, Validation o, Validation p, Validation q, Validation r, Validation s, Validation t) {
		return (Validation)Applicative.apply(fun, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t);
	}

	public static > Validation apply(Function21 fun, Validation a, Validation b, Validation c, Validation d, Validation e, Validation f, Validation g, Validation h, Validation i, Validation j, Validation k, Validation l, Validation m, Validation n, Validation o, Validation p, Validation q, Validation r, Validation s, Validation t, Validation u) {
		return (Validation)Applicative.apply(fun, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u);
	}

	public static > Validation apply(Function22 fun, Validation a, Validation b, Validation c, Validation d, Validation e, Validation f, Validation g, Validation h, Validation i, Validation j, Validation k, Validation l, Validation m, Validation n, Validation o, Validation p, Validation q, Validation r, Validation s, Validation t, Validation u, Validation v) {
		return (Validation)Applicative.apply(fun, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v);
	}

	public static > Validation apply(Function23 fun, Validation a, Validation b, Validation c, Validation d, Validation e, Validation f, Validation g, Validation h, Validation i, Validation j, Validation k, Validation l, Validation m, Validation n, Validation o, Validation p, Validation q, Validation r, Validation s, Validation t, Validation u, Validation v, Validation w) {
		return (Validation)Applicative.apply(fun, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w);
	}

	public static > Validation apply(Function24 fun, Validation a, Validation b, Validation c, Validation d, Validation e, Validation f, Validation g, Validation h, Validation i, Validation j, Validation k, Validation l, Validation m, Validation n, Validation o, Validation p, Validation q, Validation r, Validation s, Validation t, Validation u, Validation v, Validation w, Validation x) {
		return (Validation)Applicative.apply(fun, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x);
	}

	public static > Validation apply(Function25 fun, Validation a, Validation b, Validation c, Validation d, Validation e, Validation f, Validation g, Validation h, Validation i, Validation j, Validation k, Validation l, Validation m, Validation n, Validation o, Validation p, Validation q, Validation r, Validation s, Validation t, Validation u, Validation v, Validation w, Validation x, Validation y) {
		return (Validation)Applicative.apply(fun, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y);
	}

	public static > Validation apply(Function26 fun, Validation a, Validation b, Validation c, Validation d, Validation e, Validation f, Validation g, Validation h, Validation i, Validation j, Validation k, Validation l, Validation m, Validation n, Validation o, Validation p, Validation q, Validation r, Validation s, Validation t, Validation u, Validation v, Validation w, Validation x, Validation y, Validation z) {
		return (Validation)Applicative.apply(fun, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z);
	}

	public static > Function3> wrap(CheckedFunction3 fun, Function error) {
		return (a, b, c) -> {
			try {
				return new Success<>(fun.apply(a, b, c));
			}
			catch (Exception ex) {
				return new Failure<>(error.apply(ex));
			}
		};
	}

	public static  Function3 ignore(CheckedFunction3 fun) {
		return (a, b, c) -> {
			try {
				return fun.apply(a, b, c);
			}
			catch (Exception ex) {
				throw new RuntimeException(ex);
			}
		};
	}

	public static > Function4> wrap(CheckedFunction4 fun, Function error) {
		return (a, b, c, d) -> {
			try {
				return new Success<>(fun.apply(a, b, c, d));
			}
			catch (Exception ex) {
				return new Failure<>(error.apply(ex));
			}
		};
	}

	public static  Function4 ignore(CheckedFunction4 fun) {
		return (a, b, c, d) -> {
			try {
				return fun.apply(a, b, c, d);
			}
			catch (Exception ex) {
				throw new RuntimeException(ex);
			}
		};
	}

	public static > Function5> wrap(CheckedFunction5 fun, Function error) {
		return (a, b, c, d, e) -> {
			try {
				return new Success<>(fun.apply(a, b, c, d, e));
			}
			catch (Exception ex) {
				return new Failure<>(error.apply(ex));
			}
		};
	}

	public static  Function5 ignore(CheckedFunction5 fun) {
		return (a, b, c, d, e) -> {
			try {
				return fun.apply(a, b, c, d, e);
			}
			catch (Exception ex) {
				throw new RuntimeException(ex);
			}
		};
	}

	public static > Function6> wrap(CheckedFunction6 fun, Function error) {
		return (a, b, c, d, e, f) -> {
			try {
				return new Success<>(fun.apply(a, b, c, d, e, f));
			}
			catch (Exception ex) {
				return new Failure<>(error.apply(ex));
			}
		};
	}

	public static  Function6 ignore(CheckedFunction6 fun) {
		return (a, b, c, d, e, f) -> {
			try {
				return fun.apply(a, b, c, d, e, f);
			}
			catch (Exception ex) {
				throw new RuntimeException(ex);
			}
		};
	}

	public static > Function7> wrap(CheckedFunction7 fun, Function error) {
		return (a, b, c, d, e, f, g) -> {
			try {
				return new Success<>(fun.apply(a, b, c, d, e, f, g));
			}
			catch (Exception ex) {
				return new Failure<>(error.apply(ex));
			}
		};
	}

	public static  Function7 ignore(CheckedFunction7 fun) {
		return (a, b, c, d, e, f, g) -> {
			try {
				return fun.apply(a, b, c, d, e, f, g);
			}
			catch (Exception ex) {
				throw new RuntimeException(ex);
			}
		};
	}

	public static > Function8> wrap(CheckedFunction8 fun, Function error) {
		return (a, b, c, d, e, f, g, h) -> {
			try {
				return new Success<>(fun.apply(a, b, c, d, e, f, g, h));
			}
			catch (Exception ex) {
				return new Failure<>(error.apply(ex));
			}
		};
	}

	public static  Function8 ignore(CheckedFunction8 fun) {
		return (a, b, c, d, e, f, g, h) -> {
			try {
				return fun.apply(a, b, c, d, e, f, g, h);
			}
			catch (Exception ex) {
				throw new RuntimeException(ex);
			}
		};
	}

	public static > Function9> wrap(CheckedFunction9 fun, Function error) {
		return (a, b, c, d, e, f, g, h, i) -> {
			try {
				return new Success<>(fun.apply(a, b, c, d, e, f, g, h, i));
			}
			catch (Exception ex) {
				return new Failure<>(error.apply(ex));
			}
		};
	}

	public static  Function9 ignore(CheckedFunction9 fun) {
		return (a, b, c, d, e, f, g, h, i) -> {
			try {
				return fun.apply(a, b, c, d, e, f, g, h, i);
			}
			catch (Exception ex) {
				throw new RuntimeException(ex);
			}
		};
	}

	public static > Function10> wrap(CheckedFunction10 fun, Function error) {
		return (a, b, c, d, e, f, g, h, i, j) -> {
			try {
				return new Success<>(fun.apply(a, b, c, d, e, f, g, h, i, j));
			}
			catch (Exception ex) {
				return new Failure<>(error.apply(ex));
			}
		};
	}

	public static  Function10 ignore(CheckedFunction10 fun) {
		return (a, b, c, d, e, f, g, h, i, j) -> {
			try {
				return fun.apply(a, b, c, d, e, f, g, h, i, j);
			}
			catch (Exception ex) {
				throw new RuntimeException(ex);
			}
		};
	}

	public static > Function11> wrap(CheckedFunction11 fun, Function error) {
		return (a, b, c, d, e, f, g, h, i, j, k) -> {
			try {
				return new Success<>(fun.apply(a, b, c, d, e, f, g, h, i, j, k));
			}
			catch (Exception ex) {
				return new Failure<>(error.apply(ex));
			}
		};
	}

	public static  Function11 ignore(CheckedFunction11 fun) {
		return (a, b, c, d, e, f, g, h, i, j, k) -> {
			try {
				return fun.apply(a, b, c, d, e, f, g, h, i, j, k);
			}
			catch (Exception ex) {
				throw new RuntimeException(ex);
			}
		};
	}

	public static > Function12> wrap(CheckedFunction12 fun, Function error) {
		return (a, b, c, d, e, f, g, h, i, j, k, l) -> {
			try {
				return new Success<>(fun.apply(a, b, c, d, e, f, g, h, i, j, k, l));
			}
			catch (Exception ex) {
				return new Failure<>(error.apply(ex));
			}
		};
	}

	public static  Function12 ignore(CheckedFunction12 fun) {
		return (a, b, c, d, e, f, g, h, i, j, k, l) -> {
			try {
				return fun.apply(a, b, c, d, e, f, g, h, i, j, k, l);
			}
			catch (Exception ex) {
				throw new RuntimeException(ex);
			}
		};
	}

	public static > Function13> wrap(CheckedFunction13 fun, Function error) {
		return (a, b, c, d, e, f, g, h, i, j, k, l, m) -> {
			try {
				return new Success<>(fun.apply(a, b, c, d, e, f, g, h, i, j, k, l, m));
			}
			catch (Exception ex) {
				return new Failure<>(error.apply(ex));
			}
		};
	}

	public static  Function13 ignore(CheckedFunction13 fun) {
		return (a, b, c, d, e, f, g, h, i, j, k, l, m) -> {
			try {
				return fun.apply(a, b, c, d, e, f, g, h, i, j, k, l, m);
			}
			catch (Exception ex) {
				throw new RuntimeException(ex);
			}
		};
	}

	public static > Function14> wrap(CheckedFunction14 fun, Function error) {
		return (a, b, c, d, e, f, g, h, i, j, k, l, m, n) -> {
			try {
				return new Success<>(fun.apply(a, b, c, d, e, f, g, h, i, j, k, l, m, n));
			}
			catch (Exception ex) {
				return new Failure<>(error.apply(ex));
			}
		};
	}

	public static  Function14 ignore(CheckedFunction14 fun) {
		return (a, b, c, d, e, f, g, h, i, j, k, l, m, n) -> {
			try {
				return fun.apply(a, b, c, d, e, f, g, h, i, j, k, l, m, n);
			}
			catch (Exception ex) {
				throw new RuntimeException(ex);
			}
		};
	}

	public static > Function15> wrap(CheckedFunction15 fun, Function error) {
		return (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) -> {
			try {
				return new Success<>(fun.apply(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o));
			}
			catch (Exception ex) {
				return new Failure<>(error.apply(ex));
			}
		};
	}

	public static  Function15 ignore(CheckedFunction15 fun) {
		return (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) -> {
			try {
				return fun.apply(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o);
			}
			catch (Exception ex) {
				throw new RuntimeException(ex);
			}
		};
	}

	public static > Function16> wrap(CheckedFunction16 fun, Function error) {
		return (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) -> {
			try {
				return new Success<>(fun.apply(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p));
			}
			catch (Exception ex) {
				return new Failure<>(error.apply(ex));
			}
		};
	}

	public static  Function16 ignore(CheckedFunction16 fun) {
		return (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) -> {
			try {
				return fun.apply(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p);
			}
			catch (Exception ex) {
				throw new RuntimeException(ex);
			}
		};
	}

	public static > Function17> wrap(CheckedFunction17 fun, Function error) {
		return (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q) -> {
			try {
				return new Success<>(fun.apply(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q));
			}
			catch (Exception ex) {
				return new Failure<>(error.apply(ex));
			}
		};
	}

	public static  Function17 ignore(CheckedFunction17 fun) {
		return (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q) -> {
			try {
				return fun.apply(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q);
			}
			catch (Exception ex) {
				throw new RuntimeException(ex);
			}
		};
	}

	public static > Function18> wrap(CheckedFunction18 fun, Function error) {
		return (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r) -> {
			try {
				return new Success<>(fun.apply(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r));
			}
			catch (Exception ex) {
				return new Failure<>(error.apply(ex));
			}
		};
	}

	public static  Function18 ignore(CheckedFunction18 fun) {
		return (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r) -> {
			try {
				return fun.apply(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r);
			}
			catch (Exception ex) {
				throw new RuntimeException(ex);
			}
		};
	}

	public static > Function19> wrap(CheckedFunction19 fun, Function error) {
		return (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s) -> {
			try {
				return new Success<>(fun.apply(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s));
			}
			catch (Exception ex) {
				return new Failure<>(error.apply(ex));
			}
		};
	}

	public static  Function19 ignore(CheckedFunction19 fun) {
		return (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s) -> {
			try {
				return fun.apply(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s);
			}
			catch (Exception ex) {
				throw new RuntimeException(ex);
			}
		};
	}

	public static > Function20> wrap(CheckedFunction20 fun, Function error) {
		return (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t) -> {
			try {
				return new Success<>(fun.apply(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t));
			}
			catch (Exception ex) {
				return new Failure<>(error.apply(ex));
			}
		};
	}

	public static  Function20 ignore(CheckedFunction20 fun) {
		return (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t) -> {
			try {
				return fun.apply(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t);
			}
			catch (Exception ex) {
				throw new RuntimeException(ex);
			}
		};
	}

	public static > Function21> wrap(CheckedFunction21 fun, Function error) {
		return (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u) -> {
			try {
				return new Success<>(fun.apply(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u));
			}
			catch (Exception ex) {
				return new Failure<>(error.apply(ex));
			}
		};
	}

	public static  Function21 ignore(CheckedFunction21 fun) {
		return (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u) -> {
			try {
				return fun.apply(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u);
			}
			catch (Exception ex) {
				throw new RuntimeException(ex);
			}
		};
	}

	public static > Function22> wrap(CheckedFunction22 fun, Function error) {
		return (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v) -> {
			try {
				return new Success<>(fun.apply(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v));
			}
			catch (Exception ex) {
				return new Failure<>(error.apply(ex));
			}
		};
	}

	public static  Function22 ignore(CheckedFunction22 fun) {
		return (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v) -> {
			try {
				return fun.apply(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v);
			}
			catch (Exception ex) {
				throw new RuntimeException(ex);
			}
		};
	}

	public static > Function23> wrap(CheckedFunction23 fun, Function error) {
		return (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w) -> {
			try {
				return new Success<>(fun.apply(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w));
			}
			catch (Exception ex) {
				return new Failure<>(error.apply(ex));
			}
		};
	}

	public static  Function23 ignore(CheckedFunction23 fun) {
		return (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w) -> {
			try {
				return fun.apply(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w);
			}
			catch (Exception ex) {
				throw new RuntimeException(ex);
			}
		};
	}

	public static > Function24> wrap(CheckedFunction24 fun, Function error) {
		return (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x) -> {
			try {
				return new Success<>(fun.apply(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x));
			}
			catch (Exception ex) {
				return new Failure<>(error.apply(ex));
			}
		};
	}

	public static  Function24 ignore(CheckedFunction24 fun) {
		return (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x) -> {
			try {
				return fun.apply(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x);
			}
			catch (Exception ex) {
				throw new RuntimeException(ex);
			}
		};
	}

	public static > Function25> wrap(CheckedFunction25 fun, Function error) {
		return (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y) -> {
			try {
				return new Success<>(fun.apply(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y));
			}
			catch (Exception ex) {
				return new Failure<>(error.apply(ex));
			}
		};
	}

	public static  Function25 ignore(CheckedFunction25 fun) {
		return (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y) -> {
			try {
				return fun.apply(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y);
			}
			catch (Exception ex) {
				throw new RuntimeException(ex);
			}
		};
	}

	public static > Function26> wrap(CheckedFunction26 fun, Function error) {
		return (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z) -> {
			try {
				return new Success<>(fun.apply(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z));
			}
			catch (Exception ex) {
				return new Failure<>(error.apply(ex));
			}
		};
	}

	public static  Function26 ignore(CheckedFunction26 fun) {
		return (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z) -> {
			try {
				return fun.apply(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z);
			}
			catch (Exception ex) {
				throw new RuntimeException(ex);
			}
		};
	}

}