View Javadoc

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          }
47          if (obj == null) {
48              return false;
49          }
50          if (getClass() != obj.getClass()) {
51              return false;
52          }
53          MappingEntry other = (MappingEntry) obj;
54          if (mappingValueKey == null) {
55              if (other.mappingValueKey != null) {
56                  return false;
57              }
58          } else if (!mappingValueKey.equals(other.mappingValueKey)) {
59              return false;
60          }
61          if (value == null) {
62              if (other.value != null) {
63                  return false;
64              }
65          } else if (!value.equals(other.value)) {
66              return false;
67          }
68          return true;
69      }
70  
71      @Override
72      public String toString() {
73          return "MappingEntry: " + value.toString();
74      }
75  }