@Test public void testMapBy() { List<Employee> list = Lists.list(new Employee("Bob"), new Employee("Sally")); List<HRObject> wrap = (List<HRObject>) Lists.mapBy(list, new Object() { HRObject hr(Employee e) {return new HRObject(e);} }); boolean ok = wrap.get(0).name().equals("Bob") || die(); ok &= wrap.get(1).name().equals("Sally") || die(); }
public static List<?> mapBy( Object[] objects, Object instance, String methodName) { List list = new ArrayList(objects.length); for (Object o : objects) { list.add( Invoker.invoke(instance, methodName, o )); } return list; }
Lists { public static List<?> mapBy( Object[] objects, Object instance, String methodName) { List list = new ArrayList(objects.length); for (Object o : objects) { list.add( Invoker.invoke(instance, methodName, o )); } return list; } }
Lists { public static List<?> mapBy( Object[] objects, Object instance, String methodName) { List list = new ArrayList(objects.length); for (Object o : objects) { list.add( Invoker.invoke(instance, methodName, o )); } return list; }  }
Lists { public static List<?> mapBy( Object[] objects, Object instance, String methodName) { List list = new ArrayList(objects.length); for (Object o : objects) { list.add( Invoker.invoke(instance, methodName, o )); } 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  ); @Universal 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 IntList toIntList( List<?> inputList, String propertyPath ); static FloatList toFloatList( List<?> inputList, String propertyPath ); static DoubleList toDoubleList( List<?> inputList, String propertyPath ); static LongList toLongList( List<?> inputList, 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 ); @Universal static int len( List<?> list ); @Universal static int lengthOf( List<?> list ); static boolean isEmpty( List<?> list ); @Universal static boolean in( V value, List<?> list ); @Universal static void add( List<V> list, V value ); @Universal static void add( List<V> list, V... values ); @Universal static T atIndex( List<T> list, final int index ); @Universal 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 ); @Universal static void atIndex( List<V> list, int index, V v ); @Universal static void idx( List<V> list, int index, V v ); @Universal static List<V> sliceOf( List<V> list, int startIndex, int endIndex ); @Universal static List<V> slc( List<V> list, int startIndex, int endIndex ); @Universal static List<V> sliceOf( List<V> list, int startIndex ); @Universal static List<V> slc( List<V> list, int startIndex ); @Universal static List<V> endSliceOf( List<V> list, int endIndex ); @Universal static List<V> slcEnd( List<V> list, int endIndex ); @Universal static List<V> copy( List<V> list ); @Universal static List<V> copy( CopyOnWriteArrayList<V> list ); @Universal static List<V> copy( ArrayList<V> list ); @Universal static List<V> copy( LinkedList<V> list ); @Universal 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 List<N> mapBy( final Iterable<V> array, Function<V, N> function ); static SUM reduceBy( final Iterable<V> array, Reducer<V, SUM> 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); }
Lists { public static List<?> mapBy( Object[] objects, Object instance, String methodName) { List list = new ArrayList(objects.length); for (Object o : objects) { list.add( Invoker.invoke(instance, methodName, o )); } 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  ); @Universal 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 IntList toIntList( List<?> inputList, String propertyPath ); static FloatList toFloatList( List<?> inputList, String propertyPath ); static DoubleList toDoubleList( List<?> inputList, String propertyPath ); static LongList toLongList( List<?> inputList, 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 ); @Universal static int len( List<?> list ); @Universal static int lengthOf( List<?> list ); static boolean isEmpty( List<?> list ); @Universal static boolean in( V value, List<?> list ); @Universal static void add( List<V> list, V value ); @Universal static void add( List<V> list, V... values ); @Universal static T atIndex( List<T> list, final int index ); @Universal 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 ); @Universal static void atIndex( List<V> list, int index, V v ); @Universal static void idx( List<V> list, int index, V v ); @Universal static List<V> sliceOf( List<V> list, int startIndex, int endIndex ); @Universal static List<V> slc( List<V> list, int startIndex, int endIndex ); @Universal static List<V> sliceOf( List<V> list, int startIndex ); @Universal static List<V> slc( List<V> list, int startIndex ); @Universal static List<V> endSliceOf( List<V> list, int endIndex ); @Universal static List<V> slcEnd( List<V> list, int endIndex ); @Universal static List<V> copy( List<V> list ); @Universal static List<V> copy( CopyOnWriteArrayList<V> list ); @Universal static List<V> copy( ArrayList<V> list ); @Universal static List<V> copy( LinkedList<V> list ); @Universal 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 List<N> mapBy( final Iterable<V> array, Function<V, N> function ); static SUM reduceBy( final Iterable<V> array, Reducer<V, SUM> 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);  }