package org.openecomp.sdc.common.util; import fj.data.Either; import java.util.function.BiFunction; import java.util.function.Function; public class EitherPair { private Either firstEither; private Either secondEither; private EitherPair(Either firstEither, Either secondEither) { this.firstEither = firstEither; this.secondEither = secondEither; } public static EitherPair from(Either firstEither, Either secondEither) { return new EitherPair<>(firstEither, secondEither); } public X either(BiFunction onLeft, Function onRight) { if (firstEither.isRight()) { return onRight.apply(firstEither.right().value()); } if (secondEither.isRight()) { return onRight.apply(secondEither.right().value()); } return onLeft.apply(firstEither.left().value(), secondEither.left().value()); } }