- @Beta
- public static Status forArgumentString(final String argumentString) {
- switch (argumentString) {
- case "current":
- return CURRENT;
- case "deprecated":
- return DEPRECATED;
- case "obsolete":
- return OBSOLETE;
- default:
- throw new IllegalArgumentException("Invalid status string '" + argumentString + "'");
+ /**
+ * Return a {@link Status} for specified {@code status} statement argument. This methods returns a {@code null} for
+ * illegal values. See {@link #ofArgument(String)} for a version which returns non-null and throws an exception for
+ * illegal values.
+ *
+ * @param argument {@code status} statement argument
+ * @return An enumeration value, or {@code null} if specified argument is not valid
+ * @throws NullPointerException if {@code argument} is {@code null}
+ */
+ public static @Nullable Status forArgument(final String argument) {
+ return switch (argument) {
+ case "current" -> CURRENT;
+ case "deprecated" -> DEPRECATED;
+ case "obsolete" -> OBSOLETE;
+ default -> null;
+ };
+ }
+
+ /**
+ * Return a {@link Status} for specified {@code status} statement argument. This methods throws an exception for
+ * illegal values. See {@link #forArgument(String)} for a version which returns a {@code null} instead for illegal
+ * values.
+ *
+ * @param argument {@code status} statement argument
+ * @return An enumeration value, or {@code null} if specified argument is not valid
+ * @throws NullPointerException if {@code argument} is {@code null}
+ * @throws IllegalArgumentException if {@code argument} is not a valid {@code status} statement argument
+ */
+ public static Status ofArgument(final String argument) {
+ final var ret = forArgument(argument);
+ if (ret == null) {
+ throw new IllegalArgumentException("\"" + argument + "\" is not a valid status statement argument");