/** * Returns the validation id from this string. * Use this instead of valueOf to match string on the (canonical) dash-separated form. * * @return the matching validation id or empty if none */ public static Optional<ValidationId> from(String id) { for (ValidationId candidate : ValidationId.values()) if (id.equals(candidate.toString())) return Optional.of(candidate); return Optional.empty(); }