use of com.thecoderscorner.menu.domain.EnumMenuItemBuilder in project tcMenu by davetcc.
the class UIEnumMenuItem method getChangedMenuItem.
@Override
protected Optional<EnumMenuItem> getChangedMenuItem() {
List<FieldError> errors = new ArrayList<>();
ObservableList<String> items = listView.getItems();
if (items.isEmpty()) {
errors.add(new FieldError("There must be at least one choice", "Choices"));
} else if (items.stream().anyMatch(str -> str.isEmpty() || str.matches(".*[\"\\\\].*$"))) {
errors.add(new FieldError("Choices must not contain speech marks or backslash", "Choices"));
}
EnumMenuItemBuilder builder = EnumMenuItemBuilder.anEnumMenuItemBuilder().withExisting(getMenuItem()).withEnumList(items);
getChangedDefaults(builder, errors);
return getItemOrReportError(builder.menuItem(), errors);
}
Aggregations