Fix error message typo
[netconf.git] / restconf / restconf-nb-rfc8040 / src / main / java / org / opendaylight / restconf / nb / rfc8040 / ContentParam.java
index f4f6fa54380b2e22c769afed6d90865b970536ac..35a9248af9f98650c0234f40c3c838db2cd0f326 100644 (file)
@@ -10,7 +10,6 @@ package org.opendaylight.restconf.nb.rfc8040;
 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
@@ -30,6 +29,10 @@ public enum ContentParam implements RestconfQueryParam<ContentParam> {
      */
     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) {
@@ -43,7 +46,7 @@ public enum ContentParam implements RestconfQueryParam<ContentParam> {
 
     @Override
     public final String paramName() {
-        return uriName();
+        return uriName;
     }
 
     @Override
@@ -51,12 +54,7 @@ public enum ContentParam implements RestconfQueryParam<ContentParam> {
         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;
@@ -65,7 +63,8 @@ public enum ContentParam implements RestconfQueryParam<ContentParam> {
             case "nonconfig":
                 return NONCONFIG;
             default:
-                return null;
+                throw new IllegalArgumentException(
+                    "Value can be 'all', 'config' or 'nonconfig', not '" + uriValue + "'");
         }
     }
 }