22 lines
445 B
Java
22 lines
445 B
Java
package nouritsu.types;
|
|
|
|
import io.vavr.collection.Stream;
|
|
import io.vavr.control.Either;
|
|
|
|
public enum Section {
|
|
CANS,
|
|
FRUITS,
|
|
VEGETABLES,
|
|
PASTA,
|
|
RICE,
|
|
MEAT,
|
|
DAIRY,
|
|
HYGIENE;
|
|
|
|
public static Either<Resp, Section> tryParse(String catName) {
|
|
return Stream.of(Section.values())
|
|
.find(c -> c.name().equalsIgnoreCase(catName))
|
|
.toEither(Resp.BAD_REQUEST.apply("Category “%s” not found".formatted(catName)));
|
|
}
|
|
}
|