/** Returns a copy of this instance, also copying each SegmentInfo. */
 @Override
 public SegmentInfos clone() {
   try {
     final SegmentInfos sis = (SegmentInfos) super.clone();
     // deep clone, first recreate all collections:
     sis.segments = new ArrayList<>(size());
     for (final SegmentCommitInfo info : this) {
       assert info.info.getCodec() != null;
       // dont directly access segments, use add method!!!
       sis.add(info.clone());
     }
     sis.userData = new HashMap<>(userData);
     return sis;
   } catch (CloneNotSupportedException e) {
     throw new RuntimeException("should not happen", e);
   }
 }
Beispiel #2
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);
   }
 }