gICS_2.8.6
HashMapWrapper.java
1 package org.emau.icmvc.ganimed.ttp.cm2.dto;
2 
3 /*
4  * ###license-information-start###
5  * gPAS - a Generic Pseudonym Administration Service
6  * __
7  * Copyright (C) 2014 - 2018 The MOSAIC Project - Institut fuer Community
8  * Medicine of the University Medicine Greifswald -
9  * mosaic-projekt@uni-greifswald.de
10  *
11  * concept and implementation
12  * l.geidel
13  * web client
14  * a.blumentritt, m.bialke
15  *
16  * Selected functionalities of gICS were developed as part of the MAGIC Project (funded by the DFG HO 1937/5-1).
17  *
18  * please cite our publications
19  * http://dx.doi.org/10.3414/ME14-01-0133
20  * http://dx.doi.org/10.1186/s12967-015-0545-6
21  * http://dx.doi.org/10.3205/17gmds146
22  * __
23  * This program is free software: you can redistribute it and/or modify
24  * it under the terms of the GNU Affero General Public License as published by
25  * the Free Software Foundation, either version 3 of the License, or
26  * (at your option) any later version.
27  *
28  * This program is distributed in the hope that it will be useful,
29  * but WITHOUT ANY WARRANTY; without even the implied warranty of
30  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31  * GNU General Public License for more details.
32  *
33  * You should have received a copy of the GNU Affero General Public License
34  * along with this program. If not, see <http://www.gnu.org/licenses/>.
35  * ###license-information-end###
36  */
37 
38 import java.io.Serializable;
39 import java.util.HashMap;
40 
51 public class HashMapWrapper<K, V> implements Serializable {
52 
53  private static final long serialVersionUID = -7187508614583233675L;
54  // nein, nicht final - wird vom jboss beim deserialiseren per reflection (setter) gesetzt
55  private HashMap<K, V> map;
56 
57  public HashMapWrapper() {
58  map = new HashMap<K, V>();
59  }
60 
61  public HashMapWrapper(HashMap<K, V> map) {
62  super();
63  if (map != null) {
64  this.map = map;
65  } else {
66  this.map = new HashMap<K, V>();
67  }
68  }
69 
70  public HashMap<K, V> getMap() {
71  return map;
72  }
73 
74  public void setMap(HashMap<K, V> map) {
75  if (map != null) {
76  this.map = map;
77  }
78  }
79 
80  @Override
81  public int hashCode() {
82  final int prime = 31;
83  int result = 1;
84  result = prime * result + ((map == null) ? 0 : map.hashCode());
85  return result;
86  }
87 
88  @Override
89  public boolean equals(Object obj) {
90  if (this == obj)
91  return true;
92  if (obj == null)
93  return false;
94  if (getClass() != obj.getClass())
95  return false;
96  @SuppressWarnings("unchecked")
98  if (map == null) {
99  if (other.map != null)
100  return false;
101  } else if (!map.equals(other.map))
102  return false;
103  return true;
104  }
105 }
wrapper class, because jaxb can&#39;t handle hashmaps - https://wiki.kuali.org/display/STUDENTDOC/5.2+Using+JAXB+Objects+in+Web+Services : Unfortunately, as of 2.1, this processing is only defined for bean properties and not when you marshal HashMap as a top-level object (such as a value in JAXBElement.) In such case, HashMap will be treated as a Java bean, and when you look at HashMap _as a bean it defines no getter/setter property pair...