View Javadoc
1   /*
2    * Licensed under the GPL License. You may not use this file except in compliance with the License.
3    * You may obtain a copy of the License at
4    *
5    *   https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
6    *
7    * THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
8    * WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
9    * PURPOSE.
10   */
11  package psiprobe.model;
12  
13  import java.util.Collections;
14  import java.util.HashMap;
15  import java.util.Map;
16  
17  /**
18   * A wrapper class to assist marshalling of ModelAndView.getModel() map to XML representation.
19   */
20  public class TransportableModel {
21  
22    /** The items. */
23    private Map<String, Object> items = new HashMap<>();
24  
25    /**
26     * Gets the items.
27     *
28     * @return the items
29     */
30    public Map<String, Object> getItems() {
31      return items == null ? Collections.emptyMap() : new HashMap<>(items);
32    }
33  
34    /**
35     * Sets the items.
36     *
37     * @param items the items
38     */
39    public void setItems(Map<String, Object> items) {
40      this.items = items == null ? Collections.emptyMap() : new HashMap<>(items);
41    }
42  
43    /**
44     * Put all.
45     *
46     * @param map the map
47     */
48    public void putAll(Map<String, Object> map) {
49      if (map != null) {
50        items.putAll(new HashMap<>(map));
51      }
52    }
53  
54  }