Exemple #1
0
 /** Returns a copy of this instance, also copying each SegmentInfo. */
 @Override
 public Object clone() {
   try {
     final SegmentInfos sis = (SegmentInfos) super.clone();
     // deep clone, first recreate all collections:
     sis.segments = new ArrayList<SegmentInfo>(size());
     sis.segmentSet = new HashSet<SegmentInfo>(size());
     sis.cachedUnmodifiableList = null;
     sis.cachedUnmodifiableSet = null;
     for (final SegmentInfo info : this) {
       // dont directly access segments, use add method!!!
       sis.add((SegmentInfo) info.clone());
     }
     sis.userData = new HashMap<String, String>(userData);
     return sis;
   } catch (CloneNotSupportedException e) {
     throw new RuntimeException("should not happen", e);
   }
 }