Jian Li
Committed by Gerrit Code Review

[ONOS-4014] Refactor *Id classes to extend from Identifier class

- Refactor all of *Id classes in apps package

Change-Id: I31fafbf7f15aee3a1b3b37b7c281b3f99eae0883
...@@ -19,13 +19,13 @@ ...@@ -19,13 +19,13 @@
19 */ 19 */
20 package org.onosproject.acl; 20 package org.onosproject.acl;
21 21
22 +import org.onlab.util.Identifier;
23 +
22 /** 24 /**
23 * ACL rule identifier suitable as an external key. 25 * ACL rule identifier suitable as an external key.
24 * <p>This class is immutable.</p> 26 * <p>This class is immutable.</p>
25 */ 27 */
26 -public final class RuleId { 28 +public final class RuleId extends Identifier<Long> {
27 - private final long value;
28 -
29 /** 29 /**
30 * Creates an ACL rule identifier from the specified long value. 30 * Creates an ACL rule identifier from the specified long value.
31 * 31 *
...@@ -40,7 +40,7 @@ public final class RuleId { ...@@ -40,7 +40,7 @@ public final class RuleId {
40 * Constructor for serializer. 40 * Constructor for serializer.
41 */ 41 */
42 RuleId() { 42 RuleId() {
43 - this.value = 0; 43 + super(0L);
44 } 44 }
45 45
46 /** 46 /**
...@@ -49,7 +49,7 @@ public final class RuleId { ...@@ -49,7 +49,7 @@ public final class RuleId {
49 * @param value the underlying value of this ID 49 * @param value the underlying value of this ID
50 */ 50 */
51 RuleId(long value) { 51 RuleId(long value) {
52 - this.value = value; 52 + super(value);
53 } 53 }
54 54
55 /** 55 /**
...@@ -58,28 +58,11 @@ public final class RuleId { ...@@ -58,28 +58,11 @@ public final class RuleId {
58 * @return the value 58 * @return the value
59 */ 59 */
60 public long fingerprint() { 60 public long fingerprint() {
61 - return value; 61 + return identifier;
62 - }
63 -
64 - @Override
65 - public int hashCode() {
66 - return Long.hashCode(value);
67 - }
68 -
69 - @Override
70 - public boolean equals(Object obj) {
71 - if (obj == this) {
72 - return true;
73 - }
74 - if (!(obj instanceof RuleId)) {
75 - return false;
76 - }
77 - RuleId that = (RuleId) obj;
78 - return this.value == that.value;
79 } 62 }
80 63
81 @Override 64 @Override
82 public String toString() { 65 public String toString() {
83 - return "0x" + Long.toHexString(value); 66 + return "0x" + Long.toHexString(identifier);
84 } 67 }
85 } 68 }
......
...@@ -15,26 +15,21 @@ ...@@ -15,26 +15,21 @@
15 */ 15 */
16 package org.onosproject.cordvtn; 16 package org.onosproject.cordvtn;
17 17
18 -import com.google.common.base.MoreObjects; 18 +import org.onlab.util.Identifier;
19 -
20 -import java.util.Objects;
21 19
22 import static com.google.common.base.Preconditions.checkNotNull; 20 import static com.google.common.base.Preconditions.checkNotNull;
23 21
24 /** 22 /**
25 * Representation of service identifier. 23 * Representation of service identifier.
26 */ 24 */
27 -public final class CordServiceId { 25 +public final class CordServiceId extends Identifier<String> {
28 -
29 - private final String id;
30 -
31 /** 26 /**
32 * Default constructor. 27 * Default constructor.
33 * 28 *
34 * @param id service identifier 29 * @param id service identifier
35 */ 30 */
36 private CordServiceId(String id) { 31 private CordServiceId(String id) {
37 - this.id = id; 32 + super(id);
38 } 33 }
39 34
40 /** 35 /**
...@@ -47,37 +42,4 @@ public final class CordServiceId { ...@@ -47,37 +42,4 @@ public final class CordServiceId {
47 checkNotNull(id); 42 checkNotNull(id);
48 return new CordServiceId(id); 43 return new CordServiceId(id);
49 } 44 }
50 -
51 - /**
52 - * Returns service identifier.
53 - *
54 - * @return service id
55 - */
56 - public String id() {
57 - return id;
58 - }
59 -
60 - @Override
61 - public int hashCode() {
62 - return Objects.hash(id);
63 - }
64 -
65 - @Override
66 - public boolean equals(Object obj) {
67 - if (this == obj) {
68 - return true;
69 - }
70 - if (!(obj instanceof CordServiceId)) {
71 - return false;
72 - }
73 - final CordServiceId other = (CordServiceId) obj;
74 - return Objects.equals(this.id, other.id);
75 - }
76 -
77 - @Override
78 - public String toString() {
79 - return MoreObjects.toStringHelper(this)
80 - .add("id", id)
81 - .toString();
82 - }
83 } 45 }
......
...@@ -15,23 +15,19 @@ ...@@ -15,23 +15,19 @@
15 */ 15 */
16 package org.onosproject.iptopology.api; 16 package org.onosproject.iptopology.api;
17 17
18 -import static com.google.common.base.MoreObjects.toStringHelper; 18 +import org.onlab.util.Identifier;
19 -
20 -import java.util.Objects;
21 19
22 /** 20 /**
23 * Area identifier class (32 Bit Area-ID). 21 * Area identifier class (32 Bit Area-ID).
24 */ 22 */
25 -public class AreaId { 23 +public class AreaId extends Identifier<Integer> {
26 - private final int areaId;
27 -
28 /** 24 /**
29 * Constructor to set area identifier. 25 * Constructor to set area identifier.
30 * 26 *
31 * @param areaId area id 27 * @param areaId area id
32 */ 28 */
33 public AreaId(int areaId) { 29 public AreaId(int areaId) {
34 - this.areaId = areaId; 30 + super(areaId);
35 } 31 }
36 32
37 /** 33 /**
...@@ -40,31 +36,6 @@ public class AreaId { ...@@ -40,31 +36,6 @@ public class AreaId {
40 * @return area identifier 36 * @return area identifier
41 */ 37 */
42 public int areaId() { 38 public int areaId() {
43 - return areaId; 39 + return identifier;
44 - }
45 -
46 - @Override
47 - public int hashCode() {
48 - return Objects.hash(areaId);
49 - }
50 -
51 - @Override
52 - public boolean equals(Object obj) {
53 - if (this == obj) {
54 - return true;
55 - }
56 -
57 - if (obj instanceof AreaId) {
58 - AreaId other = (AreaId) obj;
59 - return Objects.equals(areaId, other.areaId);
60 - }
61 - return false;
62 - }
63 -
64 - @Override
65 - public String toString() {
66 - return toStringHelper(this)
67 - .add("areaId", areaId)
68 - .toString();
69 } 40 }
70 } 41 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -16,23 +16,19 @@ ...@@ -16,23 +16,19 @@
16 16
17 package org.onosproject.iptopology.api; 17 package org.onosproject.iptopology.api;
18 18
19 -import static com.google.common.base.MoreObjects.toStringHelper; 19 +import org.onlab.util.Identifier;
20 -
21 -import java.util.Objects;
22 20
23 /** 21 /**
24 * Domain Identifier(32 Bit). 22 * Domain Identifier(32 Bit).
25 */ 23 */
26 -public class DomainId { 24 +public class DomainId extends Identifier<Integer> {
27 - private final int domainIdentifier;
28 -
29 /** 25 /**
30 * Constructor to initialize domain identifier. 26 * Constructor to initialize domain identifier.
31 * 27 *
32 * @param domainIdentifier domain identifier 28 * @param domainIdentifier domain identifier
33 */ 29 */
34 public DomainId(int domainIdentifier) { 30 public DomainId(int domainIdentifier) {
35 - this.domainIdentifier = domainIdentifier; 31 + super(domainIdentifier);
36 } 32 }
37 33
38 /** 34 /**
...@@ -41,31 +37,6 @@ public class DomainId { ...@@ -41,31 +37,6 @@ public class DomainId {
41 * @return domain identifier 37 * @return domain identifier
42 */ 38 */
43 public int domainIdentifier() { 39 public int domainIdentifier() {
44 - return domainIdentifier; 40 + return identifier;
45 - }
46 -
47 - @Override
48 - public int hashCode() {
49 - return Objects.hash(domainIdentifier);
50 - }
51 -
52 - @Override
53 - public boolean equals(Object obj) {
54 - if (this == obj) {
55 - return true;
56 - }
57 -
58 - if (obj instanceof DomainId) {
59 - DomainId other = (DomainId) obj;
60 - return Objects.equals(domainIdentifier, other.domainIdentifier);
61 - }
62 - return false;
63 - }
64 -
65 - @Override
66 - public String toString() {
67 - return toStringHelper(this)
68 - .add("domainIdentifier", domainIdentifier)
69 - .toString();
70 } 41 }
71 } 42 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -15,23 +15,19 @@ ...@@ -15,23 +15,19 @@
15 */ 15 */
16 package org.onosproject.iptopology.api; 16 package org.onosproject.iptopology.api;
17 17
18 -import java.util.Objects; 18 +import org.onlab.util.Identifier;
19 -
20 -import com.google.common.base.MoreObjects;
21 19
22 /** 20 /**
23 * Represents Multi-Topology IDs for a network link, node or prefix. 21 * Represents Multi-Topology IDs for a network link, node or prefix.
24 */ 22 */
25 -public class TopologyId { 23 +public class TopologyId extends Identifier<Short> {
26 - private final short topologyId;
27 -
28 /** 24 /**
29 * Constructor to initialize its parameter. 25 * Constructor to initialize its parameter.
30 * 26 *
31 * @param topologyId topology id for node/link/prefix 27 * @param topologyId topology id for node/link/prefix
32 */ 28 */
33 public TopologyId(short topologyId) { 29 public TopologyId(short topologyId) {
34 - this.topologyId = topologyId; 30 + super(topologyId);
35 } 31 }
36 32
37 /** 33 /**
...@@ -40,31 +36,6 @@ public class TopologyId { ...@@ -40,31 +36,6 @@ public class TopologyId {
40 * @return topology ID 36 * @return topology ID
41 */ 37 */
42 public short topologyId() { 38 public short topologyId() {
43 - return topologyId; 39 + return identifier;
44 - }
45 -
46 - @Override
47 - public int hashCode() {
48 - return Objects.hash(topologyId);
49 - }
50 -
51 - @Override
52 - public boolean equals(Object obj) {
53 - if (this == obj) {
54 - return true;
55 - }
56 -
57 - if (obj instanceof TopologyId) {
58 - TopologyId other = (TopologyId) obj;
59 - return Objects.equals(topologyId, other.topologyId);
60 - }
61 - return false;
62 - }
63 -
64 - @Override
65 - public String toString() {
66 - return MoreObjects.toStringHelper(getClass())
67 - .add("topologyId", topologyId)
68 - .toString();
69 } 40 }
70 } 41 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -15,17 +15,14 @@ ...@@ -15,17 +15,14 @@
15 */ 15 */
16 package org.onosproject.vtnrsc; 16 package org.onosproject.vtnrsc;
17 17
18 -import static com.google.common.base.Preconditions.checkNotNull; 18 +import org.onlab.util.Identifier;
19 -
20 -import java.util.Objects;
21 19
22 -public final class BindingHostId { 20 +import static com.google.common.base.Preconditions.checkNotNull;
23 - private final String bindingHostId;
24 21
22 +public final class BindingHostId extends Identifier<String> {
25 // Public construction is prohibited 23 // Public construction is prohibited
26 private BindingHostId(String bindingHostId) { 24 private BindingHostId(String bindingHostId) {
27 - checkNotNull(bindingHostId, "BindingHosttId cannot be null"); 25 + super(checkNotNull(bindingHostId, "BindingHosttId cannot be null"));
28 - this.bindingHostId = bindingHostId;
29 } 26 }
30 27
31 /** 28 /**
...@@ -44,29 +41,6 @@ public final class BindingHostId { ...@@ -44,29 +41,6 @@ public final class BindingHostId {
44 * @return the bindingHostId identifier 41 * @return the bindingHostId identifier
45 */ 42 */
46 public String bindingHostId() { 43 public String bindingHostId() {
47 - return bindingHostId; 44 + return identifier;
48 - }
49 -
50 - @Override
51 - public int hashCode() {
52 - return bindingHostId.hashCode();
53 - }
54 -
55 - @Override
56 - public boolean equals(Object obj) {
57 - if (this == obj) {
58 - return true;
59 - }
60 - if (obj instanceof BindingHostId) {
61 - final BindingHostId that = (BindingHostId) obj;
62 - return this.getClass() == that.getClass()
63 - && Objects.equals(this.bindingHostId, that.bindingHostId);
64 - }
65 - return false;
66 - }
67 -
68 - @Override
69 - public String toString() {
70 - return bindingHostId;
71 } 45 }
72 } 46 }
......
...@@ -15,21 +15,19 @@ ...@@ -15,21 +15,19 @@
15 */ 15 */
16 package org.onosproject.vtnrsc; 16 package org.onosproject.vtnrsc;
17 17
18 -import static com.google.common.base.MoreObjects.toStringHelper; 18 +import org.onlab.util.Identifier;
19 -import static com.google.common.base.Preconditions.checkNotNull;
20 19
21 -import java.util.Objects;
22 import java.util.UUID; 20 import java.util.UUID;
23 21
22 +import static com.google.common.base.Preconditions.checkNotNull;
23 +
24 /** 24 /**
25 * Immutable representation of a floating IP identifier. 25 * Immutable representation of a floating IP identifier.
26 */ 26 */
27 -public final class FloatingIpId { 27 +public final class FloatingIpId extends Identifier<UUID> {
28 - private final UUID floatingIpId;
29 -
30 // Public construction is prohibited 28 // Public construction is prohibited
31 private FloatingIpId(UUID floatingIpId) { 29 private FloatingIpId(UUID floatingIpId) {
32 - this.floatingIpId = checkNotNull(floatingIpId, "floatingIpId cannot be null"); 30 + super(checkNotNull(floatingIpId, "floatingIpId cannot be null"));
33 } 31 }
34 32
35 /** 33 /**
...@@ -58,28 +56,6 @@ public final class FloatingIpId { ...@@ -58,28 +56,6 @@ public final class FloatingIpId {
58 * @return the floating IP identifier 56 * @return the floating IP identifier
59 */ 57 */
60 public UUID floatingIpId() { 58 public UUID floatingIpId() {
61 - return floatingIpId; 59 + return identifier;
62 - }
63 -
64 - @Override
65 - public int hashCode() {
66 - return floatingIpId.hashCode();
67 - }
68 -
69 - @Override
70 - public boolean equals(Object obj) {
71 - if (this == obj) {
72 - return true;
73 - }
74 - if (obj instanceof FloatingIpId) {
75 - final FloatingIpId that = (FloatingIpId) obj;
76 - return Objects.equals(this.floatingIpId, that.floatingIpId);
77 - }
78 - return false;
79 - }
80 -
81 - @Override
82 - public String toString() {
83 - return toStringHelper(this).add("floatingIpId", floatingIpId).toString();
84 } 60 }
85 } 61 }
......
...@@ -15,28 +15,23 @@ ...@@ -15,28 +15,23 @@
15 */ 15 */
16 package org.onosproject.vtnrsc; 16 package org.onosproject.vtnrsc;
17 17
18 -import static com.google.common.base.Preconditions.checkNotNull; 18 +import org.onlab.util.Identifier;
19 -
20 -import com.google.common.base.MoreObjects;
21 19
22 import java.util.UUID; 20 import java.util.UUID;
23 -import java.util.Objects; 21 +
22 +import static com.google.common.base.Preconditions.checkNotNull;
24 23
25 /** 24 /**
26 * Flow classification identifier. 25 * Flow classification identifier.
27 */ 26 */
28 -public final class FlowClassifierId { 27 +public final class FlowClassifierId extends Identifier<UUID> {
29 -
30 - private final UUID flowClassifierId;
31 -
32 /** 28 /**
33 * Constructor to create flow classifier id. 29 * Constructor to create flow classifier id.
34 * 30 *
35 * @param flowClassifierId flow classifier id. 31 * @param flowClassifierId flow classifier id.
36 */ 32 */
37 private FlowClassifierId(final UUID flowClassifierId) { 33 private FlowClassifierId(final UUID flowClassifierId) {
38 - checkNotNull(flowClassifierId, "Flow classifier id can not be null"); 34 + super(checkNotNull(flowClassifierId, "Flow classifier id can not be null"));
39 - this.flowClassifierId = flowClassifierId;
40 } 35 }
41 36
42 /** 37 /**
...@@ -65,30 +60,6 @@ public final class FlowClassifierId { ...@@ -65,30 +60,6 @@ public final class FlowClassifierId {
65 * @return flow classifier id. 60 * @return flow classifier id.
66 */ 61 */
67 public UUID value() { 62 public UUID value() {
68 - return flowClassifierId; 63 + return identifier;
69 - }
70 -
71 - @Override
72 - public int hashCode() {
73 - return Objects.hashCode(this.flowClassifierId);
74 - }
75 -
76 - @Override
77 - public boolean equals(Object obj) {
78 - if (this == obj) {
79 - return true;
80 - }
81 - if (obj instanceof FlowClassifierId) {
82 - final FlowClassifierId other = (FlowClassifierId) obj;
83 - return Objects.equals(this.flowClassifierId, other.flowClassifierId);
84 - }
85 - return false;
86 - }
87 -
88 - @Override
89 - public String toString() {
90 - return MoreObjects.toStringHelper(getClass())
91 - .add("FlowClassifierId", flowClassifierId)
92 - .toString();
93 } 64 }
94 } 65 }
......
...@@ -15,19 +15,16 @@ ...@@ -15,19 +15,16 @@
15 */ 15 */
16 package org.onosproject.vtnrsc; 16 package org.onosproject.vtnrsc;
17 17
18 -import static com.google.common.base.Preconditions.checkArgument; 18 +import org.onlab.util.Identifier;
19 -
20 -import java.util.Objects;
21 19
22 -import com.google.common.base.MoreObjects; 20 +import static com.google.common.base.Preconditions.checkArgument;
23 21
24 /* 22 /*
25 * Representation of 5 bit load balance identifier for a service function 23 * Representation of 5 bit load balance identifier for a service function
26 */ 24 */
27 -public final class LoadBalanceId { 25 +public final class LoadBalanceId extends Identifier<Byte> {
28 26
29 private static final byte MAX_ID = 0x1F; 27 private static final byte MAX_ID = 0x1F;
30 - private final byte loadBalanceId;
31 28
32 /** 29 /**
33 * Default constructor. 30 * Default constructor.
...@@ -35,8 +32,8 @@ public final class LoadBalanceId { ...@@ -35,8 +32,8 @@ public final class LoadBalanceId {
35 * @param loadBalanceId service function chain path's load balance identifier 32 * @param loadBalanceId service function chain path's load balance identifier
36 */ 33 */
37 private LoadBalanceId(byte loadBalanceId) { 34 private LoadBalanceId(byte loadBalanceId) {
35 + super(loadBalanceId);
38 checkArgument(loadBalanceId <= MAX_ID, "Load balance id should not be more than 5 bit identifier"); 36 checkArgument(loadBalanceId <= MAX_ID, "Load balance id should not be more than 5 bit identifier");
39 - this.loadBalanceId = (loadBalanceId);
40 } 37 }
41 38
42 /** 39 /**
...@@ -56,31 +53,6 @@ public final class LoadBalanceId { ...@@ -56,31 +53,6 @@ public final class LoadBalanceId {
56 * @return loadBalanceId 53 * @return loadBalanceId
57 */ 54 */
58 public byte loadBalanceId() { 55 public byte loadBalanceId() {
59 - return loadBalanceId; 56 + return identifier;
60 - }
61 -
62 -
63 - @Override
64 - public int hashCode() {
65 - return Objects.hash(loadBalanceId);
66 - }
67 -
68 - @Override
69 - public boolean equals(Object obj) {
70 - if (this == obj) {
71 - return true;
72 - }
73 - if (!(obj instanceof LoadBalanceId)) {
74 - return false;
75 - }
76 - final LoadBalanceId other = (LoadBalanceId) obj;
77 - return Objects.equals(this.loadBalanceId, other.loadBalanceId);
78 - }
79 -
80 - @Override
81 - public String toString() {
82 - return MoreObjects.toStringHelper(this)
83 - .add("loadBalanceId", loadBalanceId)
84 - .toString();
85 } 57 }
86 } 58 }
......
...@@ -15,27 +15,23 @@ ...@@ -15,27 +15,23 @@
15 */ 15 */
16 package org.onosproject.vtnrsc; 16 package org.onosproject.vtnrsc;
17 17
18 -import static com.google.common.base.MoreObjects.toStringHelper; 18 +import org.onlab.util.Identifier;
19 -import static com.google.common.base.Preconditions.checkNotNull;
20 19
21 import java.util.UUID; 20 import java.util.UUID;
22 -import java.util.Objects; 21 +
22 +import static com.google.common.base.Preconditions.checkNotNull;
23 23
24 /** 24 /**
25 * Representation of a Port Chain ID. 25 * Representation of a Port Chain ID.
26 */ 26 */
27 -public final class PortChainId { 27 +public final class PortChainId extends Identifier<UUID> {
28 -
29 - private final UUID portChainId;
30 -
31 /** 28 /**
32 * Private constructor for port chain id. 29 * Private constructor for port chain id.
33 * 30 *
34 * @param id UUID id of port chain 31 * @param id UUID id of port chain
35 */ 32 */
36 private PortChainId(UUID id) { 33 private PortChainId(UUID id) {
37 - checkNotNull(id, "Port chain id can not be null"); 34 + super(checkNotNull(id, "Port chain id can not be null"));
38 - this.portChainId = id;
39 } 35 }
40 36
41 /** 37 /**
...@@ -64,28 +60,6 @@ public final class PortChainId { ...@@ -64,28 +60,6 @@ public final class PortChainId {
64 * @return port chain id 60 * @return port chain id
65 */ 61 */
66 public UUID value() { 62 public UUID value() {
67 - return portChainId; 63 + return identifier;
68 - }
69 -
70 - @Override
71 - public boolean equals(Object obj) {
72 - if (this == obj) {
73 - return true;
74 - }
75 - if (obj instanceof PortChainId) {
76 - final PortChainId other = (PortChainId) obj;
77 - return Objects.equals(this.portChainId, other.portChainId);
78 - }
79 - return false;
80 - }
81 -
82 - @Override
83 - public int hashCode() {
84 - return Objects.hashCode(this.portChainId);
85 - }
86 -
87 - @Override
88 - public String toString() {
89 - return toStringHelper(this).add("portChainId", portChainId).toString();
90 } 64 }
91 } 65 }
......
...@@ -15,27 +15,23 @@ ...@@ -15,27 +15,23 @@
15 */ 15 */
16 package org.onosproject.vtnrsc; 16 package org.onosproject.vtnrsc;
17 17
18 -import static com.google.common.base.MoreObjects.toStringHelper; 18 +import org.onlab.util.Identifier;
19 -import static com.google.common.base.Preconditions.checkNotNull;
20 19
21 import java.util.UUID; 20 import java.util.UUID;
22 -import java.util.Objects; 21 +
22 +import static com.google.common.base.Preconditions.checkNotNull;
23 23
24 /** 24 /**
25 * Representation of a Port Pair Group ID. 25 * Representation of a Port Pair Group ID.
26 */ 26 */
27 -public final class PortPairGroupId { 27 +public final class PortPairGroupId extends Identifier<UUID> {
28 -
29 - private final UUID portPairGroupId;
30 -
31 /** 28 /**
32 * Private constructor for port pair group id. 29 * Private constructor for port pair group id.
33 * 30 *
34 * @param id UUID id of port pair group 31 * @param id UUID id of port pair group
35 */ 32 */
36 private PortPairGroupId(UUID id) { 33 private PortPairGroupId(UUID id) {
37 - checkNotNull(id, "Port pair group id can not be null"); 34 + super(checkNotNull(id, "Port pair group id can not be null"));
38 - this.portPairGroupId = id;
39 } 35 }
40 36
41 /** 37 /**
...@@ -64,29 +60,6 @@ public final class PortPairGroupId { ...@@ -64,29 +60,6 @@ public final class PortPairGroupId {
64 * @return port pair group id 60 * @return port pair group id
65 */ 61 */
66 public UUID value() { 62 public UUID value() {
67 - return portPairGroupId; 63 + return identifier;
68 - }
69 -
70 - @Override
71 - public boolean equals(Object obj) {
72 - if (this == obj) {
73 - return true;
74 - }
75 - if (obj instanceof PortPairGroupId) {
76 - final PortPairGroupId other = (PortPairGroupId) obj;
77 - return Objects.equals(this.portPairGroupId, other.portPairGroupId);
78 - }
79 - return false;
80 - }
81 -
82 - @Override
83 - public int hashCode() {
84 - return Objects.hashCode(this.portPairGroupId);
85 - }
86 -
87 - @Override
88 - public String toString() {
89 - return toStringHelper(this).add("portPairGroupId", portPairGroupId)
90 - .toString();
91 } 64 }
92 } 65 }
......
...@@ -15,27 +15,23 @@ ...@@ -15,27 +15,23 @@
15 */ 15 */
16 package org.onosproject.vtnrsc; 16 package org.onosproject.vtnrsc;
17 17
18 -import static com.google.common.base.MoreObjects.toStringHelper; 18 +import org.onlab.util.Identifier;
19 -import static com.google.common.base.Preconditions.checkNotNull;
20 19
21 import java.util.UUID; 20 import java.util.UUID;
22 -import java.util.Objects; 21 +
22 +import static com.google.common.base.Preconditions.checkNotNull;
23 23
24 /** 24 /**
25 * Representation of a Port Pair ID. 25 * Representation of a Port Pair ID.
26 */ 26 */
27 -public final class PortPairId { 27 +public final class PortPairId extends Identifier<UUID> {
28 -
29 - private final UUID portPairId;
30 -
31 /** 28 /**
32 * Private constructor for port pair id. 29 * Private constructor for port pair id.
33 * 30 *
34 * @param id UUID id of port pair 31 * @param id UUID id of port pair
35 */ 32 */
36 private PortPairId(UUID id) { 33 private PortPairId(UUID id) {
37 - checkNotNull(id, "Port chain id can not be null"); 34 + super(checkNotNull(id, "Port chain id can not be null"));
38 - this.portPairId = id;
39 } 35 }
40 36
41 /** 37 /**
...@@ -64,30 +60,6 @@ public final class PortPairId { ...@@ -64,30 +60,6 @@ public final class PortPairId {
64 * @return port pair id 60 * @return port pair id
65 */ 61 */
66 public UUID value() { 62 public UUID value() {
67 - return portPairId; 63 + return identifier;
68 - }
69 -
70 - @Override
71 - public boolean equals(Object obj) {
72 - if (this == obj) {
73 - return true;
74 - }
75 - if (obj instanceof PortPairId) {
76 - final PortPairId other = (PortPairId) obj;
77 - return Objects.equals(this.portPairId, other.portPairId);
78 - }
79 - return false;
80 - }
81 -
82 - @Override
83 - public int hashCode() {
84 - return Objects.hashCode(this.portPairId);
85 - }
86 -
87 - @Override
88 - public String toString() {
89 - return toStringHelper(this)
90 - .add("portPairId", portPairId)
91 - .toString();
92 } 64 }
93 } 65 }
......
...@@ -15,22 +15,17 @@ ...@@ -15,22 +15,17 @@
15 */ 15 */
16 package org.onosproject.vtnrsc; 16 package org.onosproject.vtnrsc;
17 17
18 -import static com.google.common.base.MoreObjects.toStringHelper; 18 +import org.onlab.util.Identifier;
19 -import static com.google.common.base.Preconditions.checkNotNull;
20 19
21 -import java.util.Objects; 20 +import static com.google.common.base.Preconditions.checkNotNull;
22 21
23 /** 22 /**
24 * Immutable representation of a router identifier. 23 * Immutable representation of a router identifier.
25 */ 24 */
26 -public final class RouterId { 25 +public final class RouterId extends Identifier<String> {
27 -
28 - private final String routerId;
29 -
30 // Public construction is prohibited 26 // Public construction is prohibited
31 private RouterId(String routerId) { 27 private RouterId(String routerId) {
32 - checkNotNull(routerId, "routerId cannot be null"); 28 + super(checkNotNull(routerId, "routerId cannot be null"));
33 - this.routerId = routerId;
34 } 29 }
35 30
36 /** 31 /**
...@@ -49,29 +44,7 @@ public final class RouterId { ...@@ -49,29 +44,7 @@ public final class RouterId {
49 * @return the router identifier 44 * @return the router identifier
50 */ 45 */
51 public String routerId() { 46 public String routerId() {
52 - return routerId; 47 + return identifier;
53 - }
54 -
55 - @Override
56 - public int hashCode() {
57 - return routerId.hashCode();
58 - }
59 -
60 - @Override
61 - public boolean equals(Object obj) {
62 - if (this == obj) {
63 - return true;
64 - }
65 - if (obj instanceof RouterId) {
66 - final RouterId that = (RouterId) obj;
67 - return Objects.equals(this.routerId, that.routerId);
68 - }
69 - return false;
70 - }
71 -
72 - @Override
73 - public String toString() {
74 - return toStringHelper(this).add("routerId", routerId).toString();
75 } 48 }
76 } 49 }
77 50
......
...@@ -15,21 +15,17 @@ ...@@ -15,21 +15,17 @@
15 */ 15 */
16 package org.onosproject.vtnrsc; 16 package org.onosproject.vtnrsc;
17 17
18 -import java.util.Objects; 18 +import org.onlab.util.Identifier;
19 19
20 import static com.google.common.base.Preconditions.checkNotNull; 20 import static com.google.common.base.Preconditions.checkNotNull;
21 21
22 /** 22 /**
23 * Immutable representation of a Segmentation identifier. 23 * Immutable representation of a Segmentation identifier.
24 */ 24 */
25 -public final class SegmentationId { 25 +public final class SegmentationId extends Identifier<String> {
26 -
27 - private final String segmentationId;
28 -
29 // Public construction is prohibited 26 // Public construction is prohibited
30 private SegmentationId(String segmentationId) { 27 private SegmentationId(String segmentationId) {
31 - checkNotNull(segmentationId, "SegmentationId cannot be null"); 28 + super(checkNotNull(segmentationId, "SegmentationId cannot be null"));
32 - this.segmentationId = segmentationId;
33 } 29 }
34 30
35 /** 31 /**
...@@ -48,30 +44,6 @@ public final class SegmentationId { ...@@ -48,30 +44,6 @@ public final class SegmentationId {
48 * @return segmentationId 44 * @return segmentationId
49 */ 45 */
50 public String segmentationId() { 46 public String segmentationId() {
51 - return segmentationId; 47 + return identifier;
52 - }
53 -
54 - @Override
55 - public int hashCode() {
56 - return segmentationId.hashCode();
57 - }
58 -
59 - @Override
60 - public boolean equals(Object obj) {
61 - if (this == obj) {
62 - return true;
63 } 48 }
64 - if (obj instanceof SegmentationId) {
65 - final SegmentationId that = (SegmentationId) obj;
66 - return this.getClass() == that.getClass()
67 - && Objects.equals(this.segmentationId, that.segmentationId);
68 - }
69 - return false;
70 - }
71 -
72 - @Override
73 - public String toString() {
74 - return segmentationId;
75 - }
76 -
77 } 49 }
......
...@@ -15,21 +15,17 @@ ...@@ -15,21 +15,17 @@
15 */ 15 */
16 package org.onosproject.vtnrsc; 16 package org.onosproject.vtnrsc;
17 17
18 -import static com.google.common.base.Preconditions.checkNotNull; 18 +import org.onlab.util.Identifier;
19 19
20 -import java.util.Objects; 20 +import static com.google.common.base.Preconditions.checkNotNull;
21 21
22 /** 22 /**
23 * Immutable representation of a subnet identifier. 23 * Immutable representation of a subnet identifier.
24 */ 24 */
25 -public final class SubnetId { 25 +public final class SubnetId extends Identifier<String> {
26 -
27 - private final String subnetId;
28 -
29 // Public construction is prohibited 26 // Public construction is prohibited
30 private SubnetId(String subnetId) { 27 private SubnetId(String subnetId) {
31 - checkNotNull(subnetId, "SubnetId cannot be null"); 28 + super(checkNotNull(subnetId, "SubnetId cannot be null"));
32 - this.subnetId = subnetId;
33 } 29 }
34 30
35 /** 31 /**
...@@ -48,29 +44,6 @@ public final class SubnetId { ...@@ -48,29 +44,6 @@ public final class SubnetId {
48 * @return the subnet identifier 44 * @return the subnet identifier
49 */ 45 */
50 public String subnetId() { 46 public String subnetId() {
51 - return subnetId; 47 + return identifier;
52 - }
53 -
54 - @Override
55 - public int hashCode() {
56 - return subnetId.hashCode();
57 - }
58 -
59 - @Override
60 - public boolean equals(Object obj) {
61 - if (this == obj) {
62 - return true;
63 - }
64 - if (obj instanceof SubnetId) {
65 - final SubnetId that = (SubnetId) obj;
66 - return this.getClass() == that.getClass()
67 - && Objects.equals(this.subnetId, that.subnetId);
68 - }
69 - return false;
70 - }
71 -
72 - @Override
73 - public String toString() {
74 - return subnetId;
75 } 48 }
76 } 49 }
......
...@@ -15,20 +15,17 @@ ...@@ -15,20 +15,17 @@
15 */ 15 */
16 package org.onosproject.vtnrsc; 16 package org.onosproject.vtnrsc;
17 17
18 -import java.util.Objects; 18 +import org.onlab.util.Identifier;
19 19
20 import static com.google.common.base.Preconditions.checkNotNull; 20 import static com.google.common.base.Preconditions.checkNotNull;
21 21
22 /** 22 /**
23 * Immutable representation of a tenant identifier. 23 * Immutable representation of a tenant identifier.
24 */ 24 */
25 -public final class TenantId { 25 +public final class TenantId extends Identifier<String> {
26 -
27 - private final String tenantId;
28 -
29 // Public construction is prohibited 26 // Public construction is prohibited
30 private TenantId(String tenantId) { 27 private TenantId(String tenantId) {
31 - this.tenantId = tenantId; 28 + super(tenantId);
32 } 29 }
33 30
34 /** 31 /**
...@@ -38,7 +35,7 @@ public final class TenantId { ...@@ -38,7 +35,7 @@ public final class TenantId {
38 * @return TenantId 35 * @return TenantId
39 */ 36 */
40 public static TenantId tenantId(String tenantid) { 37 public static TenantId tenantId(String tenantid) {
41 - checkNotNull(tenantid, "Tenantid can not be null"); 38 + checkNotNull(tenantid, "Tenant id can not be null");
42 return new TenantId(tenantid); 39 return new TenantId(tenantid);
43 } 40 }
44 41
...@@ -48,30 +45,6 @@ public final class TenantId { ...@@ -48,30 +45,6 @@ public final class TenantId {
48 * @return the tenant identifier 45 * @return the tenant identifier
49 */ 46 */
50 public String tenantId() { 47 public String tenantId() {
51 - return tenantId; 48 + return identifier;
52 - }
53 -
54 - @Override
55 - public int hashCode() {
56 - return tenantId.hashCode();
57 - }
58 -
59 - @Override
60 - public boolean equals(Object obj) {
61 - if (this == obj) {
62 - return true;
63 } 49 }
64 - if (obj instanceof TenantId) {
65 - final TenantId that = (TenantId) obj;
66 - return this.getClass() == that.getClass()
67 - && Objects.equals(this.tenantId, that.tenantId);
68 - }
69 - return false;
70 - }
71 -
72 - @Override
73 - public String toString() {
74 - return tenantId;
75 - }
76 -
77 } 50 }
......
...@@ -15,19 +15,17 @@ ...@@ -15,19 +15,17 @@
15 */ 15 */
16 package org.onosproject.vtnrsc; 16 package org.onosproject.vtnrsc;
17 17
18 -import java.util.Objects; 18 +import org.onlab.util.Identifier;
19 +
19 import static com.google.common.base.Preconditions.checkNotNull; 20 import static com.google.common.base.Preconditions.checkNotNull;
20 21
21 /** 22 /**
22 * Immutable representation of a tenantNetwork identity. 23 * Immutable representation of a tenantNetwork identity.
23 */ 24 */
24 -public final class TenantNetworkId { 25 +public final class TenantNetworkId extends Identifier<String> {
25 -
26 - private final String networkId;
27 -
28 // Public construction is prohibited 26 // Public construction is prohibited
29 private TenantNetworkId(String networkId) { 27 private TenantNetworkId(String networkId) {
30 - this.networkId = networkId; 28 + super(networkId);
31 } 29 }
32 30
33 /** 31 /**
...@@ -47,30 +45,6 @@ public final class TenantNetworkId { ...@@ -47,30 +45,6 @@ public final class TenantNetworkId {
47 * @return the tenantNetwork identifier 45 * @return the tenantNetwork identifier
48 */ 46 */
49 public String networkId() { 47 public String networkId() {
50 - return networkId; 48 + return identifier;
51 - }
52 -
53 - @Override
54 - public int hashCode() {
55 - return networkId.hashCode();
56 - }
57 -
58 - @Override
59 - public boolean equals(Object obj) {
60 - if (this == obj) {
61 - return true;
62 - }
63 - if (obj instanceof TenantNetworkId) {
64 - final TenantNetworkId that = (TenantNetworkId) obj;
65 - return this.getClass() == that.getClass()
66 - && Objects.equals(this.networkId, that.networkId);
67 - }
68 - return false;
69 } 49 }
70 -
71 - @Override
72 - public String toString() {
73 - return networkId;
74 - }
75 -
76 } 50 }
......
...@@ -15,23 +15,21 @@ ...@@ -15,23 +15,21 @@
15 */ 15 */
16 package org.onosproject.vtnrsc; 16 package org.onosproject.vtnrsc;
17 17
18 -import static com.google.common.base.Preconditions.checkNotNull; 18 +import org.onlab.util.Identifier;
19 19
20 -import java.util.Objects; 20 +import static com.google.common.base.Preconditions.checkNotNull;
21 21
22 /** 22 /**
23 * Immutable representation of a virtual port identifier. 23 * Immutable representation of a virtual port identifier.
24 */ 24 */
25 -public final class VirtualPortId { 25 +public final class VirtualPortId extends Identifier<String> {
26 - private final String portId;
27 // Public construction is prohibited 26 // Public construction is prohibited
28 private VirtualPortId(String virtualPortId) { 27 private VirtualPortId(String virtualPortId) {
29 - checkNotNull(virtualPortId, "VirtualPortId cannot be null"); 28 + super(checkNotNull(virtualPortId, "VirtualPortId cannot be null"));
30 - this.portId = virtualPortId;
31 } 29 }
32 30
33 public String portId() { 31 public String portId() {
34 - return portId; 32 + return identifier;
35 } 33 }
36 34
37 /** 35 /**
...@@ -43,28 +41,4 @@ public final class VirtualPortId { ...@@ -43,28 +41,4 @@ public final class VirtualPortId {
43 public static VirtualPortId portId(String portId) { 41 public static VirtualPortId portId(String portId) {
44 return new VirtualPortId(portId); 42 return new VirtualPortId(portId);
45 } 43 }
46 -
47 - @Override
48 - public int hashCode() {
49 - return portId.hashCode();
50 - }
51 -
52 - @Override
53 - public boolean equals(Object obj) {
54 - if (this == obj) {
55 - return true;
56 - }
57 - if (obj instanceof VirtualPortId) {
58 - final VirtualPortId that = (VirtualPortId) obj;
59 - return this.getClass() == that.getClass()
60 - && Objects.equals(this.portId, that.portId);
61 - }
62 - return false;
63 - }
64 -
65 - @Override
66 - public String toString() {
67 - return portId;
68 - }
69 -
70 } 44 }
......