Closed jabrena closed 1 month ago
private List
public Either<String, Integer> properFlatMapOfEither(String age) { Either<String, String> outerEither = Option .of(age) .map(Either::<String, String>right) .getOrElse(Either.left("empty"));
Either<String, Integer> flattened = outerEither
.flatMap(e -> eitherWrapper(e));
return flattened;
}
private Either<ContractViolation, Tuple2<Section, Constraint>> findSectionInDocument( SectionConstraint sectionConstraint) { return sections().stream() .filter(sectionConstraint::matches) .map(section -> Tuple.of(section, sectionConstraint.getConstraint())) .findAny() .map(Either::<ContractViolation, Tuple2<Section, Constraint>>right) .orElseGet(() -> Either.left(missingSectionViolation(sectionConstraint))); }