[ONOS-3116] PortPairGroupId
Change-Id: I213b6638bacfe716b87393a447b0f4634f6a4c5b
Showing
4 changed files
with
15 additions
and
18 deletions
| ... | @@ -19,8 +19,7 @@ import static com.google.common.base.MoreObjects.toStringHelper; | ... | @@ -19,8 +19,7 @@ import static com.google.common.base.MoreObjects.toStringHelper; |
| 19 | import static com.google.common.base.Preconditions.checkNotNull; | 19 | import static com.google.common.base.Preconditions.checkNotNull; |
| 20 | 20 | ||
| 21 | import java.util.UUID; | 21 | import java.util.UUID; |
| 22 | - | 22 | +import java.util.Objects; |
| 23 | -import com.google.common.base.Objects; | ||
| 24 | 23 | ||
| 25 | /** | 24 | /** |
| 26 | * Representation of a Port Pair Group ID. | 25 | * Representation of a Port Pair Group ID. |
| ... | @@ -40,22 +39,22 @@ public final class PortPairGroupId { | ... | @@ -40,22 +39,22 @@ public final class PortPairGroupId { |
| 40 | } | 39 | } |
| 41 | 40 | ||
| 42 | /** | 41 | /** |
| 43 | - * Constructor to create port pair group id from UUID. | 42 | + * Returns newly created port pair group id object. |
| 44 | * | 43 | * |
| 45 | - * @param id UUID of port pair group id | 44 | + * @param id port pair group id in UUID |
| 46 | * @return object of port pair group id | 45 | * @return object of port pair group id |
| 47 | */ | 46 | */ |
| 48 | - public static PortPairGroupId portPairGroupId(UUID id) { | 47 | + public static PortPairGroupId of(UUID id) { |
| 49 | return new PortPairGroupId(id); | 48 | return new PortPairGroupId(id); |
| 50 | } | 49 | } |
| 51 | 50 | ||
| 52 | /** | 51 | /** |
| 53 | - * Constructor to create port pair group id from string. | 52 | + * Returns newly created port pair group id object. |
| 54 | * | 53 | * |
| 55 | * @param id port pair group id in string | 54 | * @param id port pair group id in string |
| 56 | * @return object of port pair group id | 55 | * @return object of port pair group id |
| 57 | */ | 56 | */ |
| 58 | - public static PortPairGroupId portPairGroupId(String id) { | 57 | + public static PortPairGroupId of(String id) { |
| 59 | return new PortPairGroupId(UUID.fromString(id)); | 58 | return new PortPairGroupId(UUID.fromString(id)); |
| 60 | } | 59 | } |
| 61 | 60 | ||
| ... | @@ -73,10 +72,9 @@ public final class PortPairGroupId { | ... | @@ -73,10 +72,9 @@ public final class PortPairGroupId { |
| 73 | if (this == obj) { | 72 | if (this == obj) { |
| 74 | return true; | 73 | return true; |
| 75 | } | 74 | } |
| 76 | - | 75 | + if (obj instanceof PortPairGroupId) { |
| 77 | - if (obj.getClass() == this.getClass()) { | 76 | + final PortPairGroupId other = (PortPairGroupId) obj; |
| 78 | - PortPairGroupId that = (PortPairGroupId) obj; | 77 | + return Objects.equals(this.portPairGroupId, other.portPairGroupId); |
| 79 | - return Objects.equal(this.portPairGroupId, that.portPairGroupId); | ||
| 80 | } | 78 | } |
| 81 | return false; | 79 | return false; |
| 82 | } | 80 | } |
| ... | @@ -88,8 +86,7 @@ public final class PortPairGroupId { | ... | @@ -88,8 +86,7 @@ public final class PortPairGroupId { |
| 88 | 86 | ||
| 89 | @Override | 87 | @Override |
| 90 | public String toString() { | 88 | public String toString() { |
| 91 | - return toStringHelper(this) | 89 | + return toStringHelper(this).add("portPairGroupId", portPairGroupId) |
| 92 | - .add("portPairGroupId", portPairGroupId.toString()) | ||
| 93 | .toString(); | 90 | .toString(); |
| 94 | } | 91 | } |
| 95 | } | 92 | } | ... | ... |
| ... | @@ -83,11 +83,11 @@ public class PortPairGroupWebResource extends AbstractWebResource { | ... | @@ -83,11 +83,11 @@ public class PortPairGroupWebResource extends AbstractWebResource { |
| 83 | @Produces(MediaType.APPLICATION_JSON) | 83 | @Produces(MediaType.APPLICATION_JSON) |
| 84 | public Response getPortPairGroup(@PathParam("group_id") String id) { | 84 | public Response getPortPairGroup(@PathParam("group_id") String id) { |
| 85 | 85 | ||
| 86 | - if (!service.exists(PortPairGroupId.portPairGroupId(id))) { | 86 | + if (!service.exists(PortPairGroupId.of(id))) { |
| 87 | return Response.status(NOT_FOUND) | 87 | return Response.status(NOT_FOUND) |
| 88 | .entity(PORT_PAIR_GROUP_NOT_FOUND).build(); | 88 | .entity(PORT_PAIR_GROUP_NOT_FOUND).build(); |
| 89 | } | 89 | } |
| 90 | - PortPairGroup portPairGroup = nullIsNotFound(service.getPortPairGroup(PortPairGroupId.portPairGroupId(id)), | 90 | + PortPairGroup portPairGroup = nullIsNotFound(service.getPortPairGroup(PortPairGroupId.of(id)), |
| 91 | PORT_PAIR_GROUP_NOT_FOUND); | 91 | PORT_PAIR_GROUP_NOT_FOUND); |
| 92 | 92 | ||
| 93 | ObjectNode result = new ObjectMapper().createObjectNode(); | 93 | ObjectNode result = new ObjectMapper().createObjectNode(); |
| ... | @@ -153,7 +153,7 @@ public class PortPairGroupWebResource extends AbstractWebResource { | ... | @@ -153,7 +153,7 @@ public class PortPairGroupWebResource extends AbstractWebResource { |
| 153 | @DELETE | 153 | @DELETE |
| 154 | public void deletePortPairGroup(@PathParam("group_id") String id) { | 154 | public void deletePortPairGroup(@PathParam("group_id") String id) { |
| 155 | log.debug("Deletes port pair group by identifier {}.", id); | 155 | log.debug("Deletes port pair group by identifier {}.", id); |
| 156 | - PortPairGroupId portPairGroupId = PortPairGroupId.portPairGroupId(id); | 156 | + PortPairGroupId portPairGroupId = PortPairGroupId.of(id); |
| 157 | Boolean issuccess = nullIsNotFound(service.removePortPairGroup(portPairGroupId), | 157 | Boolean issuccess = nullIsNotFound(service.removePortPairGroup(portPairGroupId), |
| 158 | PORT_PAIR_GROUP_NOT_FOUND); | 158 | PORT_PAIR_GROUP_NOT_FOUND); |
| 159 | if (!issuccess) { | 159 | if (!issuccess) { | ... | ... |
| ... | @@ -76,7 +76,7 @@ public final class PortChainCodec extends JsonCodec<PortChain> { | ... | @@ -76,7 +76,7 @@ public final class PortChainCodec extends JsonCodec<PortChain> { |
| 76 | ArrayNode arrayNode = (ArrayNode) json.path(PORT_PAIR_GROUPS); | 76 | ArrayNode arrayNode = (ArrayNode) json.path(PORT_PAIR_GROUPS); |
| 77 | if (arrayNode != null) { | 77 | if (arrayNode != null) { |
| 78 | List<PortPairGroupId> list = Lists.newArrayList(); | 78 | List<PortPairGroupId> list = Lists.newArrayList(); |
| 79 | - arrayNode.forEach(i -> list.add(PortPairGroupId.portPairGroupId(i.asText()))); | 79 | + arrayNode.forEach(i -> list.add(PortPairGroupId.of(i.asText()))); |
| 80 | resultBuilder.setPortPairGroups(list); | 80 | resultBuilder.setPortPairGroups(list); |
| 81 | } | 81 | } |
| 82 | 82 | ... | ... |
| ... | @@ -59,7 +59,7 @@ public final class PortPairGroupCodec extends JsonCodec<PortPairGroup> { | ... | @@ -59,7 +59,7 @@ public final class PortPairGroupCodec extends JsonCodec<PortPairGroup> { |
| 59 | 59 | ||
| 60 | String id = nullIsIllegal(json.get(ID), | 60 | String id = nullIsIllegal(json.get(ID), |
| 61 | ID + MISSING_MEMBER_MESSAGE).asText(); | 61 | ID + MISSING_MEMBER_MESSAGE).asText(); |
| 62 | - resultBuilder.setId(PortPairGroupId.portPairGroupId(id)); | 62 | + resultBuilder.setId(PortPairGroupId.of(id)); |
| 63 | 63 | ||
| 64 | String tenantId = nullIsIllegal(json.get(TENANT_ID), | 64 | String tenantId = nullIsIllegal(json.get(TENANT_ID), |
| 65 | TENANT_ID + MISSING_MEMBER_MESSAGE).asText(); | 65 | TENANT_ID + MISSING_MEMBER_MESSAGE).asText(); | ... | ... |
-
Please register or login to post a comment