Lists { public static <V> List<V> deepCopy( Collection<V> collection ) { List<V> list = new ArrayList<>(collection.size()); for (V v : collection) { list.add( BeanUtils.copy(v)); } return list; }  static List<T> lazyAdd(List<T> list, T... items); static List<T> lazyAdd(ArrayList<T> list, T... items); static List<T> safeLazyAdd(CopyOnWriteArrayList<T> list, T... items); static List<T> lazyAdd(CopyOnWriteArrayList<T> list, T... items); static List<T> lazyCreate(List<T> list); static List<T> lazyCreate(ArrayList<T> list); static List<T> lazyCreate(CopyOnWriteArrayList<T> list); static List<T> safeLazyCreate(CopyOnWriteArrayList<T> list); static T fromList( List<Object> list, Class<T> clazz ); static List<V> list( Class<V> clazz ); static List<V> copy( Collection<V> collection ); static List<V> deepCopy( Collection<V> collection ); static List<V> deepCopyToList( Collection<V> src,  List<V> dst); static List<T> deepCopy( Collection<V> src, Class<T> dest  ); static List<V> deepCopy( List<V> list ); static List<List<V>> lists( Collection<V>... collections ); static List<V> list( Iterable<V> iterable ); static List<V> list( Collection<V> collection ); static List<V> linkedList( Iterable<V> iterable ); static List<?> toListOrSingletonList( Object item ); static List<PROP> toList( List<?> inputList, Class<PROP> cls, String propertyPath ); static List<?> toList( List<?> inputList, String propertyPath ); static List<?> toList( Object item ); static List<WRAP> convert(Class<WRAP> wrapper, Iterable<V> collection ); static List<WRAP> convert(Class<WRAP> wrapper, Collection<V> collection ); static List<WRAP> convert(Class<WRAP> wrapper, V[] collection ); static List<WRAP> wrap(Class<WRAP> wrapper, Iterable<V> collection ); static List<WRAP> wrap(Class<WRAP> wrapper, Collection<V> collection ); static List<WRAP> wrap(Class<WRAP> wrapper, V[] collection ); static List<V> list( Enumeration<V> enumeration ); static Enumeration<V> enumeration( final List<V> list ); static List<V> list( Iterator<V> iterator ); @SafeVarargs static List<V> list( final V... array ); static List<V> safeList(Class<V> cls); @SafeVarargs static List<V> safeList( final V... array ); @SafeVarargs static List<V> linkedList( final V... array ); static List<V> safeList( Collection<V> collection ); static List<V> linkedList( Collection<V> collection ); static int len( List<?> list ); static int lengthOf( List<?> list ); static boolean isEmpty( List<?> list ); static boolean in( V value, List<?> list ); static void add( List<V> list, V value ); static void add( List<V> list, V... values ); static T atIndex( List<T> list, final int index ); static T idx( List<T> list, final int index ); static List idxList( List<T> list, final int index ); static Map idxMap( List<T> list, final int index ); static void atIndex( List<V> list, int index, V v ); static void idx( List<V> list, int index, V v ); static List<V> sliceOf( List<V> list, int startIndex, int endIndex ); static List<V> slc( List<V> list, int startIndex, int endIndex ); static List<V> sliceOf( List<V> list, int startIndex ); static List<V> slc( List<V> list, int startIndex ); static List<V> endSliceOf( List<V> list, int endIndex ); static List<V> slcEnd( List<V> list, int endIndex ); static List<V> copy( List<V> list ); static List<V> copy( CopyOnWriteArrayList<V> list ); static List<V> copy( ArrayList<V> list ); static List<V> copy( LinkedList<V> list ); static void insert( List<V> list, int index, V v ); static List<T> listFromProperty( Class<T> propertyType, String propertyPath, Collection<?> list ); static List<T> listFromProperty( Class<T> propertyType, String propertyPath, Iterable<?> list ); static List<Map<String, Object>> toListOfMaps( List<?> list ); static void setListProperty(List<?> list, String propertyName, Object value); static List<?> mapBy( Object[] objects, Object instance, String methodName); static List<?> mapBy(Object[] objects, Class<?> cls, String methodName); static List<?> mapBy(Iterable<?> objects, Class<?> cls, String methodName); static List<?> mapBy(Iterable<?> objects, Object instance, String methodName); static List<?> mapBy(Collection<?> objects, Class<?> cls, String methodName); static List<?> mapBy(Collection<?> objects, Object function); static List<T> mapBy(Class<T> cls, Collection<?> objects, Object function); static List<?> mapBy(Iterable<?> objects, Object function); static List<?> mapBy(Object[] objects, Object function); static List<?> mapBy(Collection<?> objects, Object object, String methodName); static List<N> mapBy(  final V[] array, Function<V, N> function ); static List<N> mapBy( final Collection<V> array, Function<V, N> function ); static Object reduceBy( final Iterable<?> array, Object object ); static List<T> filterBy( final Iterable<T> array, Predicate<T> predicate ); static List<T> filterBy(  final Collection<T> array, Predicate<T> predicate ); static List<T> filterBy( Predicate<T> predicate, final T[] array ); static List<T> filterBy(  final Iterable<T> array, Object object ); static List<T> filterBy( final Collection<T> array, Object object ); static List<T> filterBy(  final T[] array, Object object ); static List<T> filterBy(  final Iterable<T> array, Object object, String methodName ); static List<T> filterBy( final Collection<T> array, Object object, String methodName ); static List<T> filterBy(  final T[] array, Object object, String methodName ); static String toPrettyJson(List list);  }
@Test public void testDeepCopy() { List<Employee> list = Lists.list(new Employee("Bob"), new Employee("Sally")); Lists.setListProperty(list, "salary", 200); List<Person> people = Lists.deepCopy(list, Person.class); ok = people.size() == 2 || die(); ok = people.get(0).name.equals("Bob"); ok = people.get(1).name.equals("Sally"); }