17 lines
526 B
Java
17 lines
526 B
Java
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<Section>sections) {
|
|
public static Either<Resp, Store> tryParse(String name, String sections) {
|
|
return Either.traverse(List.of(sections.split(",")), Section::tryParse)
|
|
.mapLeft(errors -> Resp.BAD_REQUEST.apply(errors.mkString("\n")))
|
|
.map(secs -> new Store(name, secs));
|
|
}
|
|
}
|