/** * Wraps a for loop and the creation of a new list. * * @param <T> * @param <U> * @param col * @param mapper * @return a list where the mapper has been applied to each element in the map */ public static <T, U> LinkedList<T> map( Collection<U> col, Mapper<T, U> mapper ) { LinkedList<T> list = new LinkedList<T>(); for ( U u : col ) { list.add( mapper.apply( u ) ); } return list; }
/** * Wraps a for loop and the creation of a new list. * * @param <T> * @param <U> * @param col * @param mapper * @return a list where the mapper has been applied to each element in the map */ public static <T, U> LinkedList<T> map( U[] col, Mapper<T, U> mapper ) { LinkedList<T> list = new LinkedList<T>(); for ( U u : col ) { list.add( mapper.apply( u ) ); } return list; }
@Override public Pair<List<LanguageString>, CodeType> apply( KeywordsType u ) { return new Pair<List<LanguageString>, CodeType>( map( u.getKeyword(), LANG_LANG_MAPPER ), CODETYPE_MAPPER.apply( u.getType() ) ); } };
@Override public Pair<List<LanguageString>, CodeType> apply( KeywordsType u ) { Pair<List<LanguageString>, CodeType> p = new Pair<List<LanguageString>, CodeType>(); p.first = map( u.getKeyword(), LANG_LANG_MAPPER ); if ( u.getType() != null ) { p.second = CODE_TYPE_MAPPER.apply( u.getType() ); } return p; } };