changed license year
[lispflowmapping.git] / mappingservice / api / src / main / java / org / opendaylight / lispflowmapping / interfaces / dao / MappingServiceValue.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.List;
11
12 /**
13  * A value in the mapping service. It contains a list of the RLOCs, and a
14  * password.
15  */
16 public class MappingServiceValue {
17
18     private List<MappingServiceRLOC> rlocs;
19     private String key;
20
21     private final static MappingServiceValue EMPTY_MAPPING_SERVICE_VALUE = new MappingServiceValue();
22
23     public MappingServiceValue() {
24     }
25
26     public MappingServiceValue(List<MappingServiceRLOC> rlocs, String key) {
27         this.rlocs = rlocs;
28         this.key = key;
29     }
30
31     public List<MappingServiceRLOC> getRlocs() {
32         return rlocs;
33     }
34
35     public void setRlocs(List<MappingServiceRLOC> rlocs) {
36         this.rlocs = rlocs;
37     }
38
39     public String getKey() {
40         return key;
41     }
42
43     public void setKey(String key) {
44         this.key = key;
45     }
46
47     public boolean isEmpty() {
48         return equals(EMPTY_MAPPING_SERVICE_VALUE);
49     }
50
51     @Override
52     public int hashCode() {
53         final int prime = 31;
54         int result = 1;
55         result = prime * result + ((key == null) ? 0 : key.hashCode());
56         result = prime * result + ((rlocs == null) ? 0 : rlocs.hashCode());
57         return result;
58     }
59
60     @Override
61     public boolean equals(Object obj) {
62         if (this == obj)
63             return true;
64         if (obj == null)
65             return false;
66         if (getClass() != obj.getClass())
67             return false;
68         MappingServiceValue other = (MappingServiceValue) obj;
69         if (key == null) {
70             if (other.key != null)
71                 return false;
72         } else if (!key.equals(other.key))
73             return false;
74         if (rlocs == null) {
75             if (other.rlocs != null)
76                 return false;
77         } else if (!rlocs.equals(other.rlocs))
78             return false;
79         return true;
80     }
81
82     @Override
83     public String toString() {
84         StringBuilder sb = new StringBuilder();
85         return sb.append("MappingServiceValue: Password: ").append(key).append(" RLOCs: ").append(rlocs).toString();
86     }
87
88 }