12 lines
366 B
Java
12 lines
366 B
Java
package nouritsu.types;
|
|
|
|
import io.vavr.control.Either;
|
|
|
|
public record ShoppingItem(String name, Section section) {
|
|
public static Either<Resp, ShoppingItem> tryParse(String name, String category) {
|
|
return Section.tryParse(category)
|
|
.map(c -> new ShoppingItem(name, c))
|
|
.mapLeft(msg -> Resp.BAD_REQUEST.apply(msg + Section.valuesAsString()));
|
|
}
|
|
}
|