31d8d0d5b6c1f7f15e30605f12cf8187b8fbb2a2
[lispflowmapping.git] / mappingservice / api / src / main / java / org / opendaylight / lispflowmapping / interfaces / dao / MappingEntry.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 /**
11  * A mapping service entry in the DAO
12  * 
13  * @param <V>
14  *            The type of the mapping key.
15  */
16 public class MappingEntry<V> {
17     private MappingValueKey<V> mappingValueKey;
18     private V value;
19
20     public MappingEntry(String key, V value) {
21         this.mappingValueKey = new MappingValueKey<V>(key);
22         this.value = value;
23     }
24
25     public String getKey() {
26         return mappingValueKey.getKey();
27     }
28
29     public V getValue() {
30         return value;
31     }
32
33     @Override
34     public int hashCode() {
35         final int prime = 31;
36         int result = 1;
37         result = prime * result + ((mappingValueKey == null) ? 0 : mappingValueKey.hashCode());
38         result = prime * result + ((value == null) ? 0 : value.hashCode());
39         return result;
40     }
41
42     @Override
43     public boolean equals(Object obj) {
44         if (this == obj)
45             return true;
46         if (obj == null)
47             return false;
48         if (getClass() != obj.getClass())
49             return false;
50         MappingEntry other = (MappingEntry) obj;
51         if (mappingValueKey == null) {
52             if (other.mappingValueKey != null)
53                 return false;
54         } else if (!mappingValueKey.equals(other.mappingValueKey))
55             return false;
56         if (value == null) {
57             if (other.value != null)
58                 return false;
59         } else if (!value.equals(other.value))
60             return false;
61         return true;
62     }
63
64     @Override
65     public String toString() {
66         return "MappingEntry: " + value.toString();
67     }
68 }