fj.data.optic.Traversal Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of functionaljava Show documentation
Show all versions of functionaljava Show documentation
Functional Java is an open source library that supports closures for the Java programming language
package fj.data.optic;
import fj.F;
import fj.F2;
import fj.F3;
import fj.F4;
import fj.F5;
import fj.F6;
import fj.Monoid;
import fj.P1;
import fj.control.Trampoline;
import fj.control.parallel.Promise;
import fj.data.Either;
import fj.data.IO;
import fj.data.List;
import fj.data.Option;
import fj.data.Stream;
import fj.data.Validation;
import fj.data.vector.V2;
public final class Traversal extends PTraversal {
final PTraversal pTraversal;
public Traversal(final PTraversal pTraversal) {
this.pTraversal = pTraversal;
}
@Override
public F> modifyFunctionF(final F> f) {
return pTraversal.modifyFunctionF(f);
}
@Override
public F> modifyEitherF(final F> f) {
return pTraversal.modifyEitherF(f);
}
@Override
public F> modifyIOF(final F> f) {
return pTraversal.modifyIOF(f);
}
@Override
public F> modifyTrampolineF(final F> f) {
return pTraversal.modifyTrampolineF(f);
}
@Override
public F> modifyPromiseF(final F> f) {
return pTraversal.modifyPromiseF(f);
}
@Override
public F> modifyListF(final F> f) {
return pTraversal.modifyListF(f);
}
@Override
public F> modifyOptionF(final F> f) {
return pTraversal.modifyOptionF(f);
}
@Override
public F> modifyStreamF(final F> f) {
return pTraversal.modifyStreamF(f);
}
@Override
public F> modifyP1F(final F> f) {
return pTraversal.modifyP1F(f);
}
@Override
public F> modifyValidationF(final F> f) {
return pTraversal.modifyValidationF(f);
}
@Override
public F> modifyV2F(final F> f) {
return pTraversal.modifyV2F(f);
}
@Override
public F foldMap(final Monoid monoid, final F f) {
return pTraversal.foldMap(monoid, f);
}
/** join two {@link Traversal} with the same target */
public final Traversal, A> sum(final Traversal other) {
return new Traversal<>(pTraversal.sum(other.pTraversal));
}
/***************************************************************/
/** Compose methods between a {@link Traversal} and another Optics */
/***************************************************************/
/** compose a {@link Traversal} with a {@link Setter} */
public final Setter composeSetter(final Setter other) {
return new Setter<>(pTraversal.composeSetter(other.pSetter));
}
/** compose a {@link Traversal} with a {@link Traversal} */
public final Traversal composeTraversal(final Traversal other) {
return new Traversal<>(pTraversal.composeTraversal(other.pTraversal));
}
/*********************************************************************/
/** Transformation methods to view a {@link Traversal} as another Optics */
/*********************************************************************/
/** view a {@link Traversal} as a {@link Setter} */
@Override
public final Setter asSetter() {
return new Setter<>(pTraversal.asSetter());
}
public static Traversal id() {
return new Traversal<>(PTraversal.pId());
}
public static Traversal, S> codiagonal() {
return new Traversal<>(PTraversal.pCodiagonal());
}
public static Traversal traversal(final F get1, final F get2, final F2 set) {
return new Traversal<>(PTraversal.pTraversal(get1, get2, (a1, a2, s) -> set.f(a1, a2)));
}
public static Traversal traversal(final F get1, final F get2, final F get3,
final F3 set) {
return new Traversal<>(PTraversal.pTraversal(get1, get2, get3, (a1, a2, a3, s) -> set.f(a1, a2, a3)));
}
public static Traversal traversal(final F get1, final F get2, final F get3,
final F get4,
final F4 set) {
return new Traversal<>(PTraversal.pTraversal(get1, get2, get3, get4, (a1, a2, a3, a4, s) -> set.f(a1, a2, a3, a4)));
}
public static Traversal traversal(final F get1, final F get2, final F get3,
final F get4, final F get5,
final F5 set) {
return new Traversal<>(PTraversal.pTraversal(get1, get2, get3, get4, get5,
(a1, a2, a3, a4, a5, s) -> set.f(a1, a2, a3, a4, a5)));
}
public static Traversal traversal(final F get1, final F get2, final F get3,
final F get4, final F get5, final F get6,
final F6 set) {
return new Traversal<>(PTraversal.pTraversal(get1, get2, get3, get4, get5, get6,
(a1, a2, a3, a4, a5, a6, s) -> set.f(a1, a2, a3, a4, a5, a6)));
}
}