Move integration tests to mdsal-it-parent
[lispflowmapping.git] / mappingservice / api / src / main / java / org / opendaylight / lispflowmapping / interfaces / dao / MappingServiceRLOCGroup.java
1 /*
2  * Copyright (c) 2014 Contextream, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.lispflowmapping.interfaces.dao;
9
10 import java.util.ArrayList;
11 import java.util.Date;
12 import java.util.List;
13
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.control.plane.rev150314.EidToLocatorRecord.Action;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.control.plane.rev150314.locatorrecords.LocatorRecord;
16
17 /**
18  * A RLOC in the mapping service with it's properties.
19  */
20 public class MappingServiceRLOCGroup {
21
22     private List<LocatorRecord> records;
23     private int ttl;
24     private Action action;
25     private boolean authoritative;
26     private Date registerdDate;
27
28     public MappingServiceRLOCGroup(int ttl, Action action, boolean authoritative) {
29         this(ttl, action, authoritative, new Date(System.currentTimeMillis()));
30     }
31
32     public MappingServiceRLOCGroup(int ttl, Action action, boolean authoritative, Date registerdDate) {
33         super();
34         this.records = new ArrayList<>();
35         this.ttl = ttl;
36         this.action = action;
37         this.authoritative = authoritative;
38         this.registerdDate = registerdDate;
39     }
40
41     public List<LocatorRecord> getRecords() {
42         return records;
43     }
44
45     public MappingServiceRLOCGroup addRecord(LocatorRecord record) {
46         this.records.add(record);
47         return this;
48     }
49
50     public int getTtl() {
51         return ttl;
52     }
53
54     public MappingServiceRLOCGroup setTtl(int ttl) {
55         this.ttl = ttl;
56         return this;
57     }
58
59     public Action getAction() {
60         return action;
61     }
62
63     public MappingServiceRLOCGroup setAction(Action action) {
64         this.action = action;
65         return this;
66     }
67
68     public boolean isAuthoritative() {
69         return authoritative;
70     }
71
72     public MappingServiceRLOCGroup setAuthoritative(boolean authoritative) {
73         this.authoritative = authoritative;
74         return this;
75     }
76
77     public Date getRegisterdDate() {
78         return registerdDate;
79     }
80
81     public MappingServiceRLOCGroup setRegisterdDate(Date registerdDate) {
82         this.registerdDate = registerdDate;
83         return this;
84     }
85
86     @Override
87     public int hashCode() {
88         final int prime = 31;
89         int result = 1;
90         result = prime * result + ((action == null) ? 0 : action.hashCode());
91         result = prime * result + (authoritative ? 1231 : 1237);
92         result = prime * result + ((records == null) ? 0 : records.hashCode());
93         result = prime * result + ((registerdDate == null) ? 0 : registerdDate.hashCode());
94         result = prime * result + ttl;
95         return result;
96     }
97
98     @Override
99     public boolean equals(Object obj) {
100         if (this == obj)
101             return true;
102         if (obj == null)
103             return false;
104         if (getClass() != obj.getClass())
105             return false;
106         MappingServiceRLOCGroup other = (MappingServiceRLOCGroup) obj;
107         if (action != other.action)
108             return false;
109         if (authoritative != other.authoritative)
110             return false;
111         if (records == null) {
112             if (other.records != null)
113                 return false;
114         } else if (!records.equals(other.records))
115             return false;
116         if (ttl != other.ttl)
117             return false;
118         return true;
119     }
120
121     @Override
122     public String toString() {
123         return "MappingServiceRLOCGroup [records=" + records + ", ttl=" + ttl + ", action=" + action + ", authoritative=" + authoritative
124                 + ", registerdDate=" + registerdDate + "]";
125     }
126
127 }