View Javadoc

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