View Javadoc

1   package fr.in2p3.jsaga.helpers.cloner;
2   
3   import java.util.*;
4   
5   /* ***************************************************
6   * *** Centre de Calcul de l'IN2P3 - Lyon (France) ***
7   * ***             http://cc.in2p3.fr/             ***
8   * ***************************************************
9   * File:   ObjectCloner
10  * Author: Sylvain Reynaud (sreynaud@in2p3.fr)
11  * Date:   24 oct. 2008
12  * ***************************************************
13  * Description:                                      */
14  /**
15   *
16   */
17  public class ObjectCloner<K,V> {
18      public Map<K,V> cloneMap(Map<K,V> map) throws CloneNotSupportedException {
19          Map<K,V> mapClone = new HashMap<K,V>();
20          for (Map.Entry<K,V> entry : map.entrySet()) {
21              K key = entry.getKey();
22              V value = entry.getValue();
23              mapClone.put(key, value);
24          }
25          return mapClone;
26      }
27  
28      public List<V> cloneList(List<V> list) throws CloneNotSupportedException {
29          List<V> listClone = new ArrayList<V>();
30          for (V value : list) {
31              listClone.add(value);
32          }
33          return listClone;
34      }
35  }