Added 2 new integration tests.
[lispflowmapping.git] / mappingservice / implementation / src / main / java / org / opendaylight / lispflowmapping / implementation / dao / MappingServiceKey.java
1 package org.opendaylight.lispflowmapping.implementation.dao;
2
3 import org.opendaylight.lispflowmapping.interfaces.dao.IMappingServiceKey;
4 import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.lispaddress.LispAddressContainer;
5
6 public class MappingServiceKey implements IMappingServiceKey {
7
8     private LispAddressContainer EID;
9     private int mask;
10
11     public MappingServiceKey(LispAddressContainer lispAddressContainer, int mask) {
12         this.EID = lispAddressContainer;
13         this.mask = mask;
14     }
15
16     public LispAddressContainer getEID() {
17         return EID;
18     }
19
20     public void setEID(LispAddressContainer eID) {
21         EID = eID;
22     }
23
24     public int getMask() {
25         return mask & 0xFF;
26     }
27
28     public void setMask(int mask) {
29         this.mask = mask;
30     }
31
32     @Override
33     public int hashCode() {
34         final int prime = 31;
35         int result = 1;
36         result = prime * result + ((EID == null) ? 0 : EID.hashCode());
37         result = prime * result + mask;
38         return result;
39     }
40
41     @Override
42     public boolean equals(Object obj) {
43         if (this == obj)
44             return true;
45         if (obj == null)
46             return false;
47         if (getClass() != obj.getClass())
48             return false;
49         MappingServiceKey other = (MappingServiceKey) obj;
50         if (EID == null) {
51             if (other.EID != null)
52                 return false;
53         } else if (!EID.equals(other.EID))
54             return false;
55         if (mask != other.mask)
56             return false;
57         return true;
58     }
59
60     @Override
61     public String toString() {
62         if (mask > 0) {
63             return EID.toString() + "/" + mask;
64         }
65         return EID.toString();
66     }
67
68 }