Fix PMD errors in REST API framework

Also refactored error catalog to get rid of a useless wrapper
class.

Change-Id: I0d4b190703b85cdea91da00e7f238538e7c115ec
diff --git a/src/main/java/net/onrc/onos/api/rest/RestError.java b/src/main/java/net/onrc/onos/api/rest/RestError.java
index dd61d26..548e3e5 100644
--- a/src/main/java/net/onrc/onos/api/rest/RestError.java
+++ b/src/main/java/net/onrc/onos/api/rest/RestError.java
@@ -8,7 +8,7 @@
  */
 public final class RestError {
 
-    private final RestErrorCodes.RestErrorCode code;
+    private final RestErrorCode code;
     private final String summary;
     private final String formattedDescription;
 
@@ -18,7 +18,7 @@
     private RestError() {
         // This is never called, but Java requires these initializations
         // because the members are final.
-        code = RestErrorCodes.RestErrorCode.INTENT_ALREADY_EXISTS;
+        code = RestErrorCode.INTENT_ALREADY_EXISTS;
         summary = "";
         formattedDescription = "";
     }
@@ -30,7 +30,7 @@
      * @param summary summary string for the new error
      * @param formattedDescription formatted full description of the error
      */
-    private RestError(final RestErrorCodes.RestErrorCode code,
+    private RestError(final RestErrorCode code,
                       final String summary,
                       final String formattedDescription) {
         this.code = code;
@@ -43,7 +43,7 @@
      *
      * @return error code
      */
-    public RestErrorCodes.RestErrorCode getCode() {
+    public RestErrorCode getCode() {
         return code;
     }
 
@@ -74,7 +74,7 @@
      *                   the description
      * @return new RestError representing this intance
      */
-    public static RestError createRestError(final RestErrorCodes.RestErrorCode code,
+    public static RestError createRestError(final RestErrorCode code,
                                             final Object... parameters) {
         final RestErrorCatalogEntry error = RestErrorCatalog.getRestError(code);
         final String formattedDescription =
diff --git a/src/main/java/net/onrc/onos/api/rest/RestErrorCatalog.java b/src/main/java/net/onrc/onos/api/rest/RestErrorCatalog.java
index fde6133..e1418fc 100644
--- a/src/main/java/net/onrc/onos/api/rest/RestErrorCatalog.java
+++ b/src/main/java/net/onrc/onos/api/rest/RestErrorCatalog.java
@@ -11,37 +11,42 @@
 public final class RestErrorCatalog {
 
     /**
-     * Hide the default constructor of a utility class.
-     */
-    private RestErrorCatalog() { }
-
-    /**
      * Static list of known errors.  Someday this will be read in from an
      * external file.
      */
     private static final RestErrorCatalogEntry[] ERROR_LIST = {
-        new RestErrorCatalogEntry(RestErrorCodes.RestErrorCode.INTENT_NOT_FOUND,
+        new RestErrorCatalogEntry(RestErrorCode.INTENT_NOT_FOUND,
                       "Intent not found",
                       "An intent with the identifier {} was not found."),
-        new RestErrorCatalogEntry(RestErrorCodes.RestErrorCode.INTENT_ALREADY_EXISTS,
+        new RestErrorCatalogEntry(RestErrorCode.INTENT_ALREADY_EXISTS,
                       "Intent already exists",
                       "An intent with the identifier {} could not be created " +
                       "because one already exists."),
-        new RestErrorCatalogEntry(RestErrorCodes.RestErrorCode.INTENT_NO_PATH,
+        new RestErrorCatalogEntry(RestErrorCode.INTENT_NO_PATH,
                       "No path found",
                       "No path found between {} and {}"),
-        new RestErrorCatalogEntry(RestErrorCodes.RestErrorCode.INTENT_INVALID,
+        new RestErrorCatalogEntry(RestErrorCode.INTENT_INVALID,
                       "Intent invalid",
                       "The intent provided is empty or invalid"),
     };
 
     /**
+     * Hide the default constructor of a utility class.
+     */
+    private RestErrorCatalog() { }
+
+    /**
      * Singleton implementation using the demand holder idiom.
      */
-    private static class RestErrorMapHolder {
+    private static final class RestErrorMapHolder {
         private static Map<Integer, RestErrorCatalogEntry> restErrorMap = initializeRestErrorMap();
 
         /**
+         * Hide the default constructor.
+         */
+        private RestErrorMapHolder() {}
+
+        /**
          * Load up the error map.
          *
          * @return REST error map
@@ -82,7 +87,7 @@
      * @return the REST error for the code if one exists, null if it does not
      *         exist.
      */
-    public static RestErrorCatalogEntry getRestError(final RestErrorCodes.RestErrorCode code) {
+    public static RestErrorCatalogEntry getRestError(final RestErrorCode code) {
         return getRestErrorMap().get(code.ordinal());
     }
 
diff --git a/src/main/java/net/onrc/onos/api/rest/RestErrorCatalogEntry.java b/src/main/java/net/onrc/onos/api/rest/RestErrorCatalogEntry.java
index 96b3eea..f4900a3 100644
--- a/src/main/java/net/onrc/onos/api/rest/RestErrorCatalogEntry.java
+++ b/src/main/java/net/onrc/onos/api/rest/RestErrorCatalogEntry.java
@@ -12,7 +12,7 @@
 
 public final class RestErrorCatalogEntry {
 
-    private final RestErrorCodes.RestErrorCode code;
+    private final RestErrorCode code;
     private final String summary;
     private final String descriptionFormatString;
 
@@ -23,7 +23,7 @@
      * @param newSummary short summary for the new error
      * @param newDescriptionFormatString formatable description for the new error
      */
-    public RestErrorCatalogEntry(final RestErrorCodes.RestErrorCode newCode,
+    public RestErrorCatalogEntry(final RestErrorCode newCode,
                                  final String newSummary,
                                  final String newDescriptionFormatString) {
         code = newCode;
@@ -45,7 +45,7 @@
      *
      * @return unique code
      */
-    public RestErrorCodes.RestErrorCode getCode() {
+    public RestErrorCode getCode() {
         return code;
     }
 
diff --git a/src/main/java/net/onrc/onos/api/rest/RestErrorCode.java b/src/main/java/net/onrc/onos/api/rest/RestErrorCode.java
new file mode 100644
index 0000000..1ff9186
--- /dev/null
+++ b/src/main/java/net/onrc/onos/api/rest/RestErrorCode.java
@@ -0,0 +1,21 @@
+package net.onrc.onos.api.rest;
+
+/**
+ * Enumeration of the ONOS defined error codes.
+ */
+public enum RestErrorCode {
+
+    // TODO: These are made up just for testing purposes.
+
+    /** Intent not found. */
+    INTENT_NOT_FOUND,
+
+    /** Intent already exists. */
+    INTENT_ALREADY_EXISTS,
+
+    /** No path available for the Intent. */
+    INTENT_NO_PATH,
+
+    /** An object specified for an intent is invalid (parsing error). */
+    INTENT_INVALID
+}
diff --git a/src/main/java/net/onrc/onos/api/rest/RestErrorCodes.java b/src/main/java/net/onrc/onos/api/rest/RestErrorCodes.java
deleted file mode 100644
index 09626d2..0000000
--- a/src/main/java/net/onrc/onos/api/rest/RestErrorCodes.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package net.onrc.onos.api.rest;
-
-/**
- * Holder class for constants that describe the REST error codes.
- */
-public final class RestErrorCodes {
-
-    /**
-     * Hidden default constructor for utility class.
-     */
-    private RestErrorCodes() { }
-
-    /**
-     * Enumeration of the ONOS defined error codes.
-     */
-    public enum RestErrorCode {
-
-        // TODO: These are made up just for testing purposes.
-
-        /** Intent not found. */
-        INTENT_NOT_FOUND,
-
-        /** Intent already exists. */
-        INTENT_ALREADY_EXISTS,
-
-        /** No path available for the Intent. */
-        INTENT_NO_PATH,
-
-        /** An object specified for an intent is invalid (parsing error). */
-        INTENT_INVALID
-    }
-
-}