1 package org.opendaylight.groupbasedpolicy.resolver;
3 import javax.annotation.concurrent.Immutable;
5 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.EndpointGroupId;
6 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.TenantId;
8 import com.google.common.collect.ComparisonChain;
9 import com.google.common.collect.Ordering;
12 * A tuple referencing an endpoint group and its enclosing tenant
16 public class EgKey implements Comparable<EgKey> {
17 private final TenantId tenantId;
18 private final EndpointGroupId egId;
20 public int hashCode() {
23 result = prime * result + ((egId == null) ? 0 : egId.hashCode());
24 result = prime * result +
25 ((tenantId == null) ? 0 : tenantId.hashCode());
29 public boolean equals(Object obj) {
34 if (getClass() != obj.getClass())
36 EgKey other = (EgKey) obj;
38 if (other.egId != null)
40 } else if (!egId.equals(other.egId))
42 if (tenantId == null) {
43 if (other.tenantId != null)
45 } else if (!tenantId.equals(other.tenantId))
49 public EgKey(TenantId tenantId, EndpointGroupId egId) {
51 this.tenantId = tenantId;
56 public int compareTo(EgKey o) {
58 if (tenantId != null) tid = tenantId.getValue();
60 if (o.tenantId != null) otid = o.tenantId.getValue();
62 if (egId != null) egid = egId.getValue();
64 if (o.egId != null) oegid = o.egId.getValue();
65 return ComparisonChain.start()
67 Ordering.natural().nullsLast())
69 Ordering.natural().nullsLast())
74 public String toString() {
75 return "EgKey [tenantId=" + tenantId + ", egId=" + egId + "]";
77 public TenantId getTenantId() {
80 public EndpointGroupId getEgId() {