List of usage examples for com.google.common.collect ImmutableList.Builder add
boolean add(E e);
From source file:co.cask.cdap.internal.app.runtime.batch.MapReduceClassLoader.java
/** * Creates the delegating list of ClassLoader. *///from w ww . j ava 2s . co m private static List<ClassLoader> createDelegates(Parameters parameters) { ImmutableList.Builder<ClassLoader> builder = ImmutableList.builder(); builder.add(parameters.getProgramClassLoader()); builder.addAll(parameters.getFilteredPluginClassLoaders()); builder.add(MapReduceClassLoader.class.getClassLoader()); return builder.build(); }
From source file:com.google.acai.Dependencies.java
/** * Returns a topological sorting./*from www.j a v a 2s .c o m*/ * * <p>Algorithm due to Kahn, Arthur B. (1962), Topological sorting of large networks, * Communications of the ACM 5 (11): 558562, * <a href="http://dl.acm.org/citation.cfm?doid=368996.369025">doi:10.1145/368996.369025</a>. */ private static ImmutableList<TestingService> topologicalSorting(DirectedGraph<TestingService> dependencyGraph) { Queue<TestingService> rootVertices = new ArrayDeque<>(dependencyGraph.getRootVertices()); ImmutableList.Builder<TestingService> ordered = ImmutableList.builder(); while (!rootVertices.isEmpty()) { TestingService vertex = rootVertices.remove(); ordered.add(vertex); for (TestingService successor : dependencyGraph.getSuccessors(vertex)) { dependencyGraph.removeEdge(vertex, successor); if (dependencyGraph.isRootVertex(successor)) { rootVertices.add(successor); } } } if (dependencyGraph.hasEdges()) { throw new IllegalArgumentException("Cycle exists in @DependsOn dependencies."); } return ordered.build(); }
From source file:com.spectralogic.ds3autogen.java.generators.requestmodels.GetObjectRequestGenerator.java
/** * Creates the constructor for the get object request that uses WritableByteChannel *//*from ww w . ja v a 2s . c om*/ protected static RequestConstructor createChannelConstructor(final ImmutableList<Arguments> constructorArgs, final ImmutableList<Arguments> optionalArgs, final ImmutableList<QueryParam> queryParams, final String requestName, final Ds3DocSpec docSpec) { final ImmutableList.Builder<Arguments> constructorArgBuilder = ImmutableList.builder(); constructorArgBuilder.addAll(constructorArgs); constructorArgBuilder.addAll(optionalArgs); constructorArgBuilder.add(new Arguments("WritableByteChannel", "Channel")); final ImmutableList.Builder<QueryParam> queryParamsBuilder = ImmutableList.builder(); queryParamsBuilder.addAll(queryParams); queryParamsBuilder.addAll(argsToQueryParams(optionalArgs)); final ImmutableList<Arguments> updatedConstructorArgs = constructorArgBuilder.build(); final ImmutableList<String> argNames = updatedConstructorArgs.stream().map(Arguments::getName) .collect(GuavaCollectors.immutableList()); return new RequestConstructor(updatedConstructorArgs, updatedConstructorArgs, queryParamsBuilder.build(), toConstructorDocs(requestName, argNames, docSpec, 1)); }
From source file:com.spectralogic.ds3autogen.c.converters.StructConverter.java
private static ImmutableList<StructMember> convertDs3Elements(final ImmutableList<Ds3Element> elementsList, final ImmutableSet<String> enumNames, final boolean isPaginated) throws ParseException { final ImmutableList.Builder<StructMember> builder = ImmutableList.builder(); for (final Ds3Element currentElement : elementsList) { final C_Type elementType = C_TypeHelper.convertDs3ElementType(currentElement, enumNames); builder.add(new StructMember(elementType, StructHelper.getNameUnderscores(currentElement.getName()), Ds3ElementUtil.getXmlTagName(currentElement), Ds3ElementUtil.getEncapsulatingTagAnnotations(currentElement.getDs3Annotations()), Ds3ElementUtil.isAttribute(currentElement.getDs3Annotations()), hasWrapper(currentElement))); if (elementType.isArray()) { builder.add(new StructMember(new PrimitiveType("size_t", false), "num_" + StructHelper.getNameUnderscores(currentElement.getName()))); }// w w w.j av a 2s.c o m if (isPaginated) { builder.add(new StructMember(new FreeableType("ds3_paging", false), "paging")); } } return builder.build(); }
From source file:org.apache.arrow.vector.types.pojo.Field.java
public static Field convertField(org.apache.arrow.flatbuf.Field field) { String name = field.name();/*from ww w .j a va2 s .c o m*/ boolean nullable = field.nullable(); ArrowType type = getTypeForField(field); DictionaryEncoding dictionaryEncoding = field.dictionary(); Long dictionary = null; if (dictionaryEncoding != null) { dictionary = dictionaryEncoding.id(); } ImmutableList.Builder<org.apache.arrow.vector.schema.VectorLayout> layout = ImmutableList.builder(); for (int i = 0; i < field.layoutLength(); ++i) { layout.add(new org.apache.arrow.vector.schema.VectorLayout(field.layout(i))); } ImmutableList.Builder<Field> childrenBuilder = ImmutableList.builder(); for (int i = 0; i < field.childrenLength(); i++) { childrenBuilder.add(convertField(field.children(i))); } List<Field> children = childrenBuilder.build(); return new Field(name, nullable, type, dictionary, children, new TypeLayout(layout.build())); }
From source file:com.google.devtools.build.lib.rules.android.DataBinding.java
/** * Processes deps that also apply data binding. * * @param ruleContext the current rule//w ww . ja v a2 s. co m * @param attributes java compilation attributes. The directories of the deps' metadata outputs * (see {@link #getMetadataOutputs}) are added to this rule's annotation processor classpath. * @return the deps' metadata outputs. These need to be staged as compilation inputs to the * current rule. */ static ImmutableList<Artifact> processDeps(RuleContext ruleContext, JavaTargetAttributes.Builder attributes) { ImmutableList.Builder<Artifact> dataBindingJavaInputs = ImmutableList.<Artifact>builder(); dataBindingJavaInputs.add(DataBinding.getLayoutInfoFile(ruleContext)); for (UsesDataBindingProvider p : ruleContext.getPrerequisites("deps", RuleConfiguredTarget.Mode.TARGET, UsesDataBindingProvider.class)) { for (Artifact dataBindingDepMetadata : p.getMetadataOutputs()) { attributes.addProcessorPathDir(dataBindingDepMetadata.getExecPath().getParentDirectory()); dataBindingJavaInputs.add(dataBindingDepMetadata); } } return dataBindingJavaInputs.build(); }
From source file:ru.org.linux.spring.ShowCommentsController.java
private static List<DeletedListItem> getDeletedComments(Connection db, int userid) throws SQLException { Statement st = db.createStatement(); ResultSet rs = st.executeQuery( "SELECT sections.name as ptitle, groups.title as gtitle, topics.title, topics.id as msgid, del_info.reason, deldate FROM sections, groups, topics, comments, del_info WHERE sections.id=groups.section AND groups.id=topics.groupid AND comments.topic=topics.id AND del_info.msgid=comments.id AND comments.userid=" + userid + " AND del_info.delby!=" + userid + " ORDER BY del_info.delDate DESC NULLS LAST, del_info.msgid DESC LIMIT 20;"); ImmutableList.Builder<DeletedListItem> builder = ImmutableList.builder(); while (rs.next()) { builder.add(new DeletedListItem(rs)); }/*from ww w . j a v a 2s .c om*/ rs.close(); st.close(); return builder.build(); }
From source file:io.crate.sql.parser.TreeAssertions.java
private static List<Node> linearizeTree(Node tree) { final ImmutableList.Builder<Node> nodes = ImmutableList.builder(); new DefaultTraversalVisitor<Node, Void>() { @Override/*from w w w .ja v a2s .c o m*/ public Node process(Node node, @Nullable Void context) { Node result = super.process(node, context); nodes.add(node); return result; } }.process(tree, null); return nodes.build(); }
From source file:me.yanaga.guava.stream.MoreCollectors.java
public static <T> Collector<T, ?, ImmutableList<T>> toImmutableList() { return Collector.of(ImmutableList::builder, new BiConsumer<ImmutableList.Builder<T>, T>() { @Override/*from w w w . ja v a 2s .c om*/ public void accept(ImmutableList.Builder<T> objectBuilder, T t) { objectBuilder.add(t); } }, new BinaryOperator<ImmutableList.Builder<T>>() { @Override public ImmutableList.Builder<T> apply(ImmutableList.Builder<T> objectBuilder, ImmutableList.Builder<T> objectBuilder2) { return objectBuilder.addAll(objectBuilder2.build()); } }, new Function<ImmutableList.Builder<T>, ImmutableList<T>>() { @Override public ImmutableList<T> apply(ImmutableList.Builder<T> tBuilder) { return tBuilder.build(); } }, UNORDERED, CONCURRENT); }
From source file:com.google.api.tools.framework.util.ProtoHelpers.java
@Nullable public static <MessageType extends GeneratedMessage.ExtendableMessage<MessageType>, Type extends GeneratedMessage> List<Type> getRepeatedExtensionObjects( GeneratedMessage.ExtendableMessageOrBuilder<MessageType> mob, ExtensionLite<MessageType, List<Type>> extension) { ImmutableList.Builder extensionList = ImmutableList.builder(); int extensionCount = mob.getExtensionCount(extension); for (int extensionIndex = 0; extensionIndex < extensionCount; ++extensionIndex) { extensionList.add(mob.getExtension(extension, extensionIndex)); }// w w w . j a v a 2 s .c om return extensionList.build(); }