[ONOS-2563]Optimize RFC 7047's code.
Change-Id: I000f2b802420e4f47ce320f6ed021049bd2fd83e
diff --git a/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/error/AbnormalSchemaException.java b/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/error/AbnormalJsonNodeException.java
similarity index 70%
rename from ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/error/AbnormalSchemaException.java
rename to ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/error/AbnormalJsonNodeException.java
index 8a32ffd..e4b1054 100644
--- a/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/error/AbnormalSchemaException.java
+++ b/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/error/AbnormalJsonNodeException.java
@@ -16,25 +16,25 @@
package org.onosproject.ovsdb.rfc.error;
/**
- * AbnormalSchema exception is thrown when the received schema is invalid.
+ * AbnormalJsonNodeException exception is thrown when the received JsonNode is invalid.
*/
-public class AbnormalSchemaException extends RuntimeException {
+public class AbnormalJsonNodeException extends RuntimeException {
private static final long serialVersionUID = 8328377718334680368L;
/**
- * Constructs a AbnormalSchemaException object.
+ * Constructs a AbnormalJsonNodeException object.
* @param message error message
*/
- public AbnormalSchemaException(String message) {
+ public AbnormalJsonNodeException(String message) {
super(message);
}
/**
- * Constructs a AbnormalSchemaException object.
+ * Constructs a AbnormalJsonNodeException object.
* @param message error message
* @param cause Throwable
*/
- public AbnormalSchemaException(String message, Throwable cause) {
+ public AbnormalJsonNodeException(String message, Throwable cause) {
super(message, cause);
}
diff --git a/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/error/ArgumentException.java b/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/error/ArgumentException.java
deleted file mode 100644
index d7d69d1..0000000
--- a/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/error/ArgumentException.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ovsdb.rfc.error;
-
-/**
- * This exception is thrown when the argument is not supported.
- */
-public class ArgumentException extends RuntimeException {
- private static final long serialVersionUID = 4950089877540156797L;
-
- /**
- * Constructs a ArgumentException object.
- * @param message error message
- */
- public ArgumentException(String message) {
- super(message);
- }
-
- /**
- * Constructs a ArgumentException object.
- * @param message error message
- * @param cause Throwable
- */
- public ArgumentException(String message, Throwable cause) {
- super(message, cause);
- }
-}
diff --git a/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/error/JsonParsingException.java b/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/error/JsonParsingException.java
deleted file mode 100644
index e62a03f..0000000
--- a/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/error/JsonParsingException.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ovsdb.rfc.error;
-
-/**
- * The JsonParsingException is thrown when JSON could not be successfully
- * parsed.
- */
-public class JsonParsingException extends RuntimeException {
- private static final long serialVersionUID = 1424752181911923235L;
-
- /**
- * Constructs a JsonParsingException object.
- * @param message error message
- */
- public JsonParsingException(String message) {
- super(message);
- }
-
- /**
- * Constructs a JsonParsingException object.
- * @param message error message
- * @param cause Throwable
- */
- public JsonParsingException(String message, Throwable cause) {
- super(message, cause);
- }
-
- /**
- * Constructs a JsonParsingException object.
- * @param cause Throwable
- */
- public JsonParsingException(Throwable cause) {
- super(cause);
- }
-
- /**
- * Constructs a JsonParsingException object.
- * @param message error message
- * @param cause Throwable
- * @param enableSuppression enable Suppression
- * @param writableStackTrace writable StackTrace
- */
- public JsonParsingException(String message, Throwable cause,
- boolean enableSuppression,
- boolean writableStackTrace) {
- super(message, cause, enableSuppression, writableStackTrace);
- }
-}
diff --git a/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/error/TypedSchemaException.java b/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/error/TypedSchemaException.java
deleted file mode 100644
index 59aea30..0000000
--- a/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/error/TypedSchemaException.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.ovsdb.rfc.error;
-
-/**
- * This is a generic exception thrown by the Typed Schema utilities.
- */
-public class TypedSchemaException extends RuntimeException {
- private static final long serialVersionUID = -1452257990783176715L;
-
- /**
- * Constructs a TypedSchemaException object.
- * @param message error message
- */
- public TypedSchemaException(String message) {
- super(message);
- }
-
- /**
- * Constructs a TypedSchemaException object.
- * @param message error message
- * @param cause Throwable
- */
- public TypedSchemaException(String message, Throwable cause) {
- super(message, cause);
- }
-}
diff --git a/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/error/UnsupportedEncodingException.java b/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/error/UnsupportedEncodingException.java
deleted file mode 100644
index 6ba7fd5..0000000
--- a/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/error/UnsupportedEncodingException.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package org.onosproject.ovsdb.rfc.error;
-
-/**
- * This exception is thrown when the encoding does not meet UTF-8 in RFC7047.
- */
-public class UnsupportedEncodingException extends RuntimeException {
- private static final long serialVersionUID = -4865311369828520666L;
-
- /**
- * Constructs a UnsupportedEncodingException object.
- * @param message error message
- */
- public UnsupportedEncodingException(String message) {
- super(message);
- }
-}
diff --git a/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/error/UnknownResultException.java b/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/error/UnsupportedException.java
similarity index 70%
rename from ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/error/UnknownResultException.java
rename to ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/error/UnsupportedException.java
index ab30fb1..a34b8d4 100644
--- a/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/error/UnknownResultException.java
+++ b/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/error/UnsupportedException.java
@@ -16,26 +16,26 @@
package org.onosproject.ovsdb.rfc.error;
/**
- * This exception is thrown when a result does not meet any of the known formats
- * in RFC7047.
+ * This exception is thrown when the caller invoke the unsupported method or
+ * use the encoding is not supported.
*/
-public class UnknownResultException extends RuntimeException {
+public class UnsupportedException extends RuntimeException {
private static final long serialVersionUID = 1377011546616825375L;
/**
- * Constructs a UnknownResultException object.
+ * Constructs a UnsupportedException object.
* @param message error message
*/
- public UnknownResultException(String message) {
+ public UnsupportedException(String message) {
super(message);
}
/**
- * Constructs a UnknownResultException object.
+ * Constructs a UnsupportedException object.
* @param message error message
* @param cause Throwable
*/
- public UnknownResultException(String message, Throwable cause) {
+ public UnsupportedException(String message, Throwable cause) {
super(message, cause);
}
}
diff --git a/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/error/VersionMismatchException.java b/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/error/VersionMismatchException.java
index 68d63b9..10d278b 100644
--- a/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/error/VersionMismatchException.java
+++ b/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/error/VersionMismatchException.java
@@ -15,7 +15,6 @@
*/
package org.onosproject.ovsdb.rfc.error;
-import static com.google.common.base.MoreObjects.toStringHelper;
/**
* This exception is used when the a table or row is accessed though a typed
@@ -47,15 +46,9 @@
* @param fromVersion the initial version
* @return message
*/
- public static String createFromMessage(String actualVersion,
- String fromVersion) {
- String message = toStringHelper("VersionMismatchException")
- .addValue("The fromVersion should less than the actualVersion.\n"
- + "fromVersion: "
- + fromVersion
- + ".\n"
- + "actualVersion: " + actualVersion)
- .toString();
+ public static String createFromMessage(String actualVersion, String fromVersion) {
+ String message = "The fromVersion should less than the actualVersion.\n fromVersion: "
+ + fromVersion + ".\n" + "actualVersion: " + actualVersion;
return message;
}
@@ -66,13 +59,8 @@
* @return message
*/
public static String createToMessage(String actualVersion, String toVersion) {
- String message = toStringHelper("VersionMismatchException")
- .addValue("The toVersion should greater than the required version.\n"
- + "toVersion: "
- + toVersion
- + ".\n"
- + "Actual Version: " + actualVersion)
- .toString();
+ String message = "The toVersion should greater than the actualVersion.\n"
+ + "toVersion: " + toVersion + ".\n" + " actualVersion: " + actualVersion;
return message;
}
}