View Javadoc

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