import static java.util.Objects.requireNonNull;
import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.jdt.annotation.Nullable;
/**
* Enumeration of possible {@code content} values as defined by
*/
NONCONFIG("nonconfig");
+ // API consistency: must not be confused with enum constants
+ @SuppressWarnings("checkstyle:ConstantName")
+ public static final @NonNull String uriName = "content";
+
private final @NonNull String uriValue;
ContentParam(final String uriValue) {
@Override
public final String paramName() {
- return uriName();
+ return uriName;
}
@Override
return uriValue;
}
- public static @NonNull String uriName() {
- return "content";
- }
-
- // Note: returns null of unknowns
- public static @Nullable ContentParam forUriValue(final String uriValue) {
+ public static @NonNull ContentParam forUriValue(final String uriValue) {
switch (uriValue) {
case "all":
return ALL;
case "nonconfig":
return NONCONFIG;
default:
- return null;
+ throw new IllegalArgumentException(
+ "Value can be 'all', 'config' or 'nonconfig', not '" + uriValue + "'");
}
}
}