List of usage examples for com.google.common.collect Iterables toArray
static <T> T[] toArray(Iterable<? extends T> iterable, T[] array)
From source file:com.google.javascript.jscomp.JsCompilerRunner.java
JsCompilerRunner(Iterable<String> args, Compiler compiler, boolean exportTestFunctions, WarningsGuard warnings) {//from w ww.j av a 2 s .co m super(Iterables.toArray(args, String.class)); this.compiler = compiler; this.exportTestFunctions = exportTestFunctions; this.warnings = warnings; }
From source file:de.flapdoodle.guava.Varargs.java
public static <T> T[] asArray(Collection<? extends T> collection, Class<T> type) { return Iterables.toArray(collection, type); }
From source file:com.android.ide.common.res2.DuplicateDataException.java
static <I extends DataItem> Message[] createMessages(@NonNull Collection<Collection<I>> duplicateDataItemSets) { List<Message> messages = Lists.newArrayListWithCapacity(duplicateDataItemSets.size()); for (Collection<I> duplicateItems : duplicateDataItemSets) { ImmutableList.Builder<SourceFilePosition> positions = ImmutableList.builder(); for (I item : duplicateItems) { if (!item.isRemoved()) { positions.add(getPosition(item)); }/*from w w w . j av a2 s .co m*/ } messages.add( new Message(Message.Kind.ERROR, DUPLICATE_RESOURCES, DUPLICATE_RESOURCES, positions.build())); } return Iterables.toArray(messages, Message.class); }
From source file:de.faustedition.collation.DiffCollator.java
public List<Alignment> align(Iterable<Token> a, Iterable<Token> b) { final Token[] at = Iterables.toArray(a, Token.class); final Token[] bt = Iterables.toArray(b, Token.class); int ai = 0;//from w w w . j a v a2 s.c o m int bi = 0; final List<Alignment> alignments = new ArrayList<Alignment>(Math.max(at.length, bt.length)); final Iterator<Difference> diffIterator = new Diff<Token>(at, bt, DEFAULT_MATCHER).diff().iterator(); Difference diff = (diffIterator.hasNext() ? diffIterator.next() : null); do { if (diff == null) { alignments.add(new Alignment(0, at[ai++], bt[bi++])); continue; } if (ai < diff.getDeletedStart() && bi < diff.getAddedStart()) { alignments.add(new Alignment(0, at[ai++], bt[bi++])); continue; } if (ai <= diff.getDeletedEnd() && bi <= diff.getAddedEnd()) { alignments.add(new Alignment(1, at[ai++], bt[bi++])); continue; } if (ai <= diff.getDeletedEnd() && bi >= diff.getAddedEnd()) { alignments.add(new Alignment(1, at[ai++], null)); continue; } if (bi <= diff.getAddedEnd() && ai >= diff.getDeletedEnd()) { alignments.add(new Alignment(1, null, bt[bi++])); continue; } diff = (diffIterator.hasNext() ? diffIterator.next() : null); } while (ai < at.length || bi < bt.length); return alignments; }
From source file:com.enonic.cms.core.resource.ResourceKey.java
private static String[] split(final String path) { final Iterable<String> result = Splitter.on("/").omitEmptyStrings().trimResults().split(path); return Iterables.toArray(result, String.class); }
From source file:edu.umn.msi.tropix.webgui.server.CatalogUtils.java
public static String[] getServiceIDsFromSHBeanList(final Iterable<SearchHit> shBeans) { return Iterables.toArray(Iterables.transform(shBeans, ENTRY_ID_FUNCTION), String.class); }
From source file:org.arbeitspferde.groningen.subject.open.ProcessServingAddressGenerator.java
public static ProcessServingAddressInfo parseAddress(final String address) { int processId; String[] addressParts = Iterables.toArray(Splitter.on("/").split(address), String.class); try {//from ww w . j av a2 s . c om processId = Integer.parseInt(addressParts[addressParts.length - 1]); } catch (NumberFormatException e) { return null; } return new ProcessServingAddressInfo(addressParts[0], addressParts[1], addressParts[2], processId); }
From source file:com.google.template.soy.jbcsrc.ConstructorRef.java
/** * Returns a new {@link ConstructorRef} that refers to a constructor on the given type with the * given parameter types./*from ww w . ja v a 2s. co m*/ */ static ConstructorRef create(TypeInfo type, Iterable<Type> argTypes) { return create(type, new Method("<init>", Type.VOID_TYPE, Iterables.toArray(argTypes, Type.class))); }
From source file:org.polymap.core.project.Layers.java
/** * Convenience for <code>Iterables.toArray( layers, ILayer.class )</code>. */// w ww . j a va2 s . c om public static ILayer[] toArray(Iterable<ILayer> layers) { return Iterables.toArray(layers, ILayer.class); }
From source file:io.dohko.jdbi.args.SqlArray.java
/** * @param type the array type/*from w w w. java 2s .c om*/ * @param elements the array elements */ public SqlArray(Class<T> type, Collection<T> elements) { this._elements = Iterables.toArray(elements, type); this._type = type; }