All pastes #810572 Raw Edit

Someone

public text v1 · immutable
·published 2007-12-10 01:55 UTC
rendered paste body
package trabalhoPDS.catalogo;

import java.util.Iterator;
import java.util.List;

public class DeepClone implements CloneStrategy {

	public List<Produto> handleChildren(List<Produto> list) {
		List<Produto> newList  = null;
		try {
			newList = list.getClass().newInstance();
		} catch (InstantiationException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		Iterator<Produto> it = list.iterator();
		while(it.hasNext()){
			try {
				newList.add(it.next().cloneProduto());
			} catch (CloneNotSupportedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

		return newList;
	}

}