package nouritsu.types; import io.vavr.collection.List; import io.vavr.collection.Seq; import io.vavr.control.Either; /** * A store with an ordered list of sections from entrance to exit. */ public record Store(String name, Seq
sections) { public static Either tryParse(String name, String sections) { return Either.traverse(List.of(sections.split(",")), Section::tryParse) .mapLeft(errors -> Resp.BAD_REQUEST.apply(errors.mkString("\n") + Section.valuesAsString())) .map(secs -> new Store(name, secs)); } }