List of usage examples for com.google.common.collect Iterators transform
public static <F, T> Iterator<T> transform(final Iterator<F> fromIterator, final Function<? super F, ? extends T> function)
From source file:org.eclipse.rdf4j.spin.function.spif.SingleValueToListTransformer.java
@SuppressWarnings("unchecked") static <E> Iterator<List<? extends E>> transform(Iterator<E> iter) { return Iterators.transform(iter, (SingleValueToListTransformer<E>) INSTANCE); }
From source file:co.cask.common.internal.asm.Methods.java
public static Method getMethod(Class<?> returnType, String name, Class<?>... args) { StringBuilder builder = new StringBuilder(returnType.getName()).append(' ').append(name).append(" ("); Joiner.on(',').appendTo(builder, Iterators.transform(Iterators.forArray(args), new Function<Class<?>, String>() { @Override//from w w w . j ava 2 s . c o m public String apply(Class<?> input) { if (input.isArray()) { return Type.getType(input.getName()).getClassName(); } return input.getName(); } })); builder.append(')'); return Method.getMethod(builder.toString()); }
From source file:org.apache.jackrabbit.oak.security.user.autosave.AuthorizableWrapper.java
static Iterator<Authorizable> createIterator(Iterator<Authorizable> dlgs, AutoSaveEnabledManager mgr) { return Iterators.transform(dlgs, new AuthorizableWrapper(mgr)); }
From source file:org.apache.fluo.recipes.core.map.Update.java
static <K2, V2> Iterator<Update<K2, V2>> transform(Iterable<Change<K2, V2>> changes) { return Iterators.transform(changes.iterator(), change -> new Update<K2, V2>(change.getKey(), change.getOldValue(), change.getNewValue())); }
From source file:org.apache.drill.exec.rpc.security.AuthStringUtil.java
public static Set<String> asSet(final List<String> list) { if (list == null) { return Sets.newHashSet(); }/*from w ww .j av a2s. com*/ return Sets.newHashSet(Iterators.transform(list.iterator(), new Function<String, String>() { @Nullable @Override public String apply(@Nullable String input) { return input == null ? null : input.toUpperCase(); } })); }
From source file:co.cask.cdap.data.file.FileWriters.java
/** * Creates a {@link FileWriter} that writes to the given {@link FileWriter} with each event transformed by the * given transformation function./*from w w w . ja v a 2 s .c om*/ * * @param writer the {@link FileWriter} to write to * @param transform the transformation function for each individual event * @param <U> source type * @param <V> target type * @return a new instance of {@link FileWriter} */ public static <U, V> FileWriter<U> transform(final FileWriter<V> writer, final Function<U, V> transform) { return new FileWriter<U>() { @Override public void append(U event) throws IOException { writer.append(transform.apply(event)); } @Override public void appendAll(Iterator<? extends U> events) throws IOException { writer.appendAll(Iterators.transform(events, transform)); } @Override public void close() throws IOException { writer.close(); } @Override public void flush() throws IOException { writer.flush(); } }; }
From source file:com.mattc.argus2.io.Configs.java
public static void applyFunctionTo(String name, Function<Object, Object> func) { Iterators.transform(getIteratorFor(name), func); }
From source file:org.caleydo.core.util.base.Labels.java
public static String join(Iterable<? extends ILabeled> labels, String separator) { return StringUtils.join(Iterators.transform(labels.iterator(), TO_LABEL), separator); }
From source file:org.apache.jackrabbit.oak.security.user.autosave.AuthorizableWrapper.java
static Iterator<Group> createGroupIterator(Iterator<Group> dlgs, AutoSaveEnabledManager mgr) { return Iterators.transform(dlgs, new AuthorizableWrapper(mgr)); }
From source file:org.apache.jackrabbit.oak.security.user.AuthorizableIterator.java
static AuthorizableIterator create(Iterator<String> authorizableOakPaths, UserManagerImpl userManager, AuthorizableType authorizableType) { Iterator it = Iterators.transform(authorizableOakPaths, new PathToAuthorizable(userManager, authorizableType)); long size = getSize(authorizableOakPaths); return new AuthorizableIterator(Iterators.filter(it, Predicates.notNull()), size); }