@SuppressWarnings("unchecked") protected static <T> Collection<T> cloneSimilarCollection(Collection<T> orig, int newCapacity) { Collection<T> answer = (Collection<T>) cloneObject(orig); if (answer != null) return answer; // fall back to creation answer = createSimilarCollection(orig, newCapacity); answer.addAll(orig); return answer; }
@SuppressWarnings("unchecked") protected static <K, V> Map<K ,V> cloneSimilarMap(Map<K, V> orig) { Map<K, V> answer = (Map<K, V>) cloneObject(orig); if (answer != null) return answer;
protected static <K, V> Map<K ,V> cloneSimilarMap(Map<K, V> orig) { Map<K, V> answer = (Map<K, V>) cloneObject(orig); if (answer != null) return answer; // fall back to some defaults if (orig instanceof TreeMap) return new TreeMap<K, V>(orig); if (orig instanceof Properties) { Map<K, V> map = (Map<K, V>) new Properties(); map.putAll(orig); return map; } if (orig instanceof Hashtable) return new Hashtable<K, V>(orig); return new LinkedHashMap<K, V>(orig); }
protected static Map cloneSimilarMap(Map orig) { Map answer = (Map) cloneObject(orig); if (answer != null) return answer; // fall back to some defaults if (orig instanceof TreeMap) return new TreeMap(orig); if (orig instanceof Properties) { Map map = new Properties(); map.putAll(orig); return map; } if (orig instanceof Hashtable) return new Hashtable(orig); return new LinkedHashMap(orig); }
@SuppressWarnings("unchecked") protected static <K, V> Map<K ,V> cloneSimilarMap(Map<K, V> orig) { Map<K, V> answer = (Map<K, V>) cloneObject(orig); if (answer != null) return answer; // fall back to some defaults if (orig instanceof TreeMap) return new TreeMap<K, V>(orig); if (orig instanceof Properties) { Map<K, V> map = (Map<K, V>) new Properties(); map.putAll(orig); return map; } if (orig instanceof Hashtable) return new Hashtable<K, V>(orig); return new LinkedHashMap<K, V>(orig); }
@SuppressWarnings("unchecked") protected static <T> Collection<T> cloneSimilarCollection(Collection<T> orig, int newCapacity) { Collection<T> answer = (Collection<T>) cloneObject(orig); if (answer != null) return answer; // fall back to creation answer = createSimilarCollection(orig, newCapacity); answer.addAll(orig); return answer; }
protected static <T> Collection<T> cloneSimilarCollection(Collection<T> orig, int newCapacity) { Collection<T> answer = (Collection<T>) cloneObject(orig); if (answer != null) return answer; // fall back to creation answer = createSimilarCollection(orig, newCapacity); answer.addAll(orig); return answer; }
protected static Collection cloneSimilarCollection(Collection orig, int newCapacity) { Collection answer = (Collection) cloneObject(orig); if (answer != null) return answer; // fall back to creation answer = createSimilarCollection(orig, newCapacity); answer.addAll(orig); return answer; }