[ONOS-3114] PortChainId
Change-Id: I3281996786b4a5acc43e5a97dc31051e443fbfca
diff --git a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/PortChainId.java b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/PortChainId.java
index 66edbdc..a42a700 100644
--- a/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/PortChainId.java
+++ b/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/PortChainId.java
@@ -19,8 +19,7 @@
import static com.google.common.base.Preconditions.checkNotNull;
import java.util.UUID;
-
-import com.google.common.base.Objects;
+import java.util.Objects;
/**
* Representation of a Port Chain ID.
@@ -40,22 +39,22 @@
}
/**
- * Constructor to create port chain id from UUID.
+ * Returns newly created port chain id object.
*
* @param id UUID of port chain
* @return object of port chain id
*/
- public static PortChainId portChainId(UUID id) {
+ public static PortChainId of(UUID id) {
return new PortChainId(id);
}
/**
- * Constructor to create port chain id from string.
+ * Returns newly created port chain id object.
*
* @param id port chain id in string
* @return object of port chain id
*/
- public static PortChainId portChainId(String id) {
+ public static PortChainId of(String id) {
return new PortChainId(UUID.fromString(id));
}
@@ -73,10 +72,9 @@
if (this == obj) {
return true;
}
-
- if (obj.getClass() == this.getClass()) {
- PortChainId that = (PortChainId) obj;
- return Objects.equal(this.portChainId, that.portChainId);
+ if (obj instanceof PortChainId) {
+ final PortChainId other = (PortChainId) obj;
+ return Objects.equals(this.portChainId, other.portChainId);
}
return false;
}
@@ -88,8 +86,6 @@
@Override
public String toString() {
- return toStringHelper(this)
- .add("portChainId", portChainId.toString())
- .toString();
+ return toStringHelper(this).add("portChainId", portChainId).toString();
}
}
diff --git a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/PortChainWebResource.java b/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/PortChainWebResource.java
index 915eda5..db12bcc 100644
--- a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/PortChainWebResource.java
+++ b/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/PortChainWebResource.java
@@ -82,10 +82,10 @@
@Produces(MediaType.APPLICATION_JSON)
public Response getPortPain(@PathParam("chain_id") String id) {
- if (!service.exists(PortChainId.portChainId(id))) {
+ if (!service.exists(PortChainId.of(id))) {
return Response.status(NOT_FOUND).entity(PORT_CHAIN_NOT_FOUND).build();
}
- PortChain portChain = nullIsNotFound(service.getPortChain(PortChainId.portChainId(id)),
+ PortChain portChain = nullIsNotFound(service.getPortChain(PortChainId.of(id)),
PORT_CHAIN_NOT_FOUND);
ObjectNode result = new ObjectMapper().createObjectNode();
result.set("port_chain", new PortChainCodec().encode(portChain, this));
@@ -147,7 +147,7 @@
@DELETE
public void deletePortPain(@PathParam("chain_id") String id) {
log.debug("Deletes port chain by identifier {}.", id);
- PortChainId portChainId = PortChainId.portChainId(id);
+ PortChainId portChainId = PortChainId.of(id);
Boolean issuccess = nullIsNotFound(service.removePortChain(portChainId), PORT_CHAIN_NOT_FOUND);
if (!issuccess) {
diff --git a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/PortChainCodec.java b/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/PortChainCodec.java
index 8c43058..1e9cf00 100644
--- a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/PortChainCodec.java
+++ b/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/PortChainCodec.java
@@ -59,7 +59,7 @@
String id = nullIsIllegal(json.get(ID),
ID + MISSING_MEMBER_MESSAGE).asText();
- resultBuilder.setId(PortChainId.portChainId(id));
+ resultBuilder.setId(PortChainId.of(id));
String tenantId = nullIsIllegal(json.get(TENANT_ID),
TENANT_ID + MISSING_MEMBER_MESSAGE).asText();