Mahesh Poojary Huawei
Committed by Ray Milkey

[ONOS-3114] PortChainId

Change-Id: I3281996786b4a5acc43e5a97dc31051e443fbfca
......@@ -19,8 +19,7 @@ import static com.google.common.base.MoreObjects.toStringHelper;
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 @@ public final class PortChainId {
}
/**
* 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 @@ public final class PortChainId {
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 @@ public final class PortChainId {
@Override
public String toString() {
return toStringHelper(this)
.add("portChainId", portChainId.toString())
.toString();
return toStringHelper(this).add("portChainId", portChainId).toString();
}
}
......
......@@ -82,10 +82,10 @@ public class PortChainWebResource extends AbstractWebResource {
@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 @@ public class PortChainWebResource extends AbstractWebResource {
@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) {
......
......@@ -59,7 +59,7 @@ public final class PortChainCodec extends JsonCodec<PortChain> {
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();
......