
org.javafunk.funk.UnaryFunctions Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of funk-core Show documentation
Show all versions of funk-core Show documentation
Functional utilities for Java: core APIs
The newest version!
/*
* Copyright (C) 2011-Present Funk committers.
* All rights reserved.
*
* The software in this package is published under the terms of the BSD
* style license a copy of which has been included with this distribution in
* the LICENSE.txt file.
*/
package org.javafunk.funk;
import org.javafunk.funk.functors.functions.UnaryFunction;
public class UnaryFunctions {
private UnaryFunctions() {}
public static UnaryFunction identity() {
return new UnaryFunction() {
@Override public T call(T input) {
return input;
}
};
}
public static UnaryFunction compose(
final UnaryFunction super Q, ? extends R> first,
final UnaryFunction super R, ? extends S> second) {
return new UnaryFunction() {
@Override public S call(Q input) {
return second.call(first.call(input));
}
};
}
public static UnaryFunction compose(
final UnaryFunction super Q, ? extends R> first,
final UnaryFunction super R, ? extends S> second,
final UnaryFunction super S, ? extends T> third) {
return new UnaryFunction() {
@Override public T call(Q input) {
return third.call(second.call(first.call(input)));
}
};
}
public static UnaryFunction compose(
final UnaryFunction super Q, ? extends R> first,
final UnaryFunction super R, ? extends S> second,
final UnaryFunction super S, ? extends T> third,
final UnaryFunction super T, ? extends U> fourth) {
return new UnaryFunction() {
@Override public U call(Q input) {
return fourth.call(third.call(second.call(first.call(input))));
}
};
}
public static UnaryFunction compose(
final UnaryFunction super Q, ? extends R> first,
final UnaryFunction super R, ? extends S> second,
final UnaryFunction super S, ? extends T> third,
final UnaryFunction super T, ? extends U> fourth,
final UnaryFunction super U, ? extends V> fifth) {
return new UnaryFunction() {
@Override public V call(Q input) {
return fifth.call(fourth.call(third.call(second.call(first.call(input)))));
}
};
}
public static UnaryFunction compose(
final UnaryFunction super Q, ? extends R> first,
final UnaryFunction super R, ? extends S> second,
final UnaryFunction super S, ? extends T> third,
final UnaryFunction super T, ? extends U> fourth,
final UnaryFunction super U, ? extends V> fifth,
final UnaryFunction super V, ? extends W> sixth) {
return new UnaryFunction() {
@Override public W call(Q input) {
return sixth.call(fifth.call(fourth.call(third.call(second.call(first.call(input))))));
}
};
}
public static UnaryFunction compose(
final UnaryFunction super Q, ? extends R> first,
final UnaryFunction super R, ? extends S> second,
final UnaryFunction super S, ? extends T> third,
final UnaryFunction super T, ? extends U> fourth,
final UnaryFunction super U, ? extends V> fifth,
final UnaryFunction super V, ? extends W> sixth,
final UnaryFunction super W, ? extends X> seventh) {
return new UnaryFunction() {
@Override public X call(Q input) {
return seventh.call(sixth.call(fifth.call(fourth.call(third.call(second.call(first.call(input)))))));
}
};
}
public static UnaryFunction compose(
final UnaryFunction super Q, ? extends R> first,
final UnaryFunction super R, ? extends S> second,
final UnaryFunction super S, ? extends T> third,
final UnaryFunction super T, ? extends U> fourth,
final UnaryFunction super U, ? extends V> fifth,
final UnaryFunction super V, ? extends W> sixth,
final UnaryFunction super W, ? extends X> seventh,
final UnaryFunction super X, ? extends Y> eighth) {
return new UnaryFunction() {
@Override public Y call(Q input) {
return eighth.call(seventh.call(sixth.call(fifth.call(fourth.call(third.call(second.call(first.call(input))))))));
}
};
}
public static UnaryFunction compose(
final UnaryFunction super Q, ? extends R> first,
final UnaryFunction super R, ? extends S> second,
final UnaryFunction super S, ? extends T> third,
final UnaryFunction super T, ? extends U> fourth,
final UnaryFunction super U, ? extends V> fifth,
final UnaryFunction super V, ? extends W> sixth,
final UnaryFunction super W, ? extends X> seventh,
final UnaryFunction super X, ? extends Y> eighth,
final UnaryFunction super Y, ? extends Z> ninth) {
return new UnaryFunction() {
@Override public Z call(Q input) {
return ninth.call(eighth.call(seventh.call(sixth.call(fifth.call(fourth.call(third.call(second.call(first.call(input)))))))));
}
};
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy