示例#1
0
  @NotNull
  public ValueContainerImpl<Value> copy() {
    ValueContainerImpl<Value> container = new ValueContainerImpl<Value>();

    if (myInputIdMapping instanceof THashMap) {
      final THashMap<Value, Object> mapping = (THashMap<Value, Object>) myInputIdMapping;
      final THashMap<Value, Object> newMapping = new THashMap<Value, Object>(mapping.size());
      container.myInputIdMapping = newMapping;

      mapping.forEachEntry(
          new TObjectObjectProcedure<Value, Object>() {
            @Override
            public boolean execute(Value key, Object val) {
              if (val instanceof ChangeBufferingList) {
                newMapping.put(key, ((ChangeBufferingList) val).clone());
              } else {
                newMapping.put(key, val);
              }
              return true;
            }
          });
    } else {
      container.myInputIdMapping = myInputIdMapping;
      container.myInputIdMappingValue =
          myInputIdMappingValue instanceof ChangeBufferingList
              ? ((ChangeBufferingList) myInputIdMappingValue).clone()
              : myInputIdMappingValue;
    }
    return container;
  }
示例#2
0
 @Override
 public ValueContainerImpl<Value> clone() {
   try {
     final ValueContainerImpl clone = (ValueContainerImpl) super.clone();
     if (myInputIdMapping instanceof THashMap) {
       clone.myInputIdMapping = mapCopy((THashMap<Value, Object>) myInputIdMapping);
     } else if (myInputIdMappingValue instanceof ChangeBufferingList) {
       clone.myInputIdMappingValue = ((ChangeBufferingList) myInputIdMappingValue).clone();
     }
     return clone;
   } catch (CloneNotSupportedException e) {
     throw new RuntimeException(e);
   }
 }