List of usage examples for com.google.common.collect ImmutableList builder
public static <E> Builder<E> builder()
From source file:com.google.template.soy.data.SoyValueConverterUtility.java
/** * Creates a new SoyList initialized from the given values. Values are converted eagerly. * * @param items A list of values.//from w w w . j a va 2 s . com * @return A new SoyEasyList initialized from the given values. */ public static SoyList newList(Object... items) { ImmutableList.Builder<SoyValueProvider> builder = ImmutableList.builder(); for (Object o : items) { builder.add(INSTANCE.convert(o)); } return ListImpl.forProviderList(builder.build()); }
From source file:org.sonar.plugins.spcaf.spcafPluginJs.java
/** * {@inheritDoc}/*from ww w . j a v a 2 s .c om*/ */ @Override public List getExtensions() { ImmutableList.Builder builder = ImmutableList.builder(); // Plugin properties and languages builder.add(PropertyDefinition.builder(JS_SUFFIXES_KEY).defaultValue(JS_SUFFIXES_DEFAULT_VALUE) .name("File Suffixes").description("Comma-separated list of suffixes for files to analyze.") .subCategory("General").onQualifiers(Qualifiers.PROJECT).build(), Js.class); return builder.build(); }
From source file:com.facebook.buck.features.ocaml.OcamlLinkStep.java
public static OcamlLinkStep create(Path workingDirectory, ImmutableMap<String, String> environment, ImmutableList<String> cxxCompiler, ImmutableList<String> ocamlCompilerCommandPrefix, ImmutableList<Arg> flags, Optional<String> stdlib, Path output, ImmutableList<Arg> depInput, ImmutableList<Arg> cDepInput, ImmutableList<Path> input, boolean isLibrary, boolean isBytecode, SourcePathResolver pathResolver) { ImmutableList.Builder<String> ocamlInputBuilder = ImmutableList.builder(); String linkExt = isBytecode ? OcamlCompilables.OCAML_CMA : OcamlCompilables.OCAML_CMXA; for (String linkInput : Arg.stringify(depInput, pathResolver)) { if (isLibrary && linkInput.endsWith(linkExt)) { continue; }// ww w .ja v a2s . com ocamlInputBuilder.add(linkInput); } ImmutableList<String> ocamlInput = ocamlInputBuilder.build(); return new OcamlLinkStep(workingDirectory, environment, cxxCompiler, ocamlCompilerCommandPrefix, Arg.stringify(flags, pathResolver), stdlib, output, ocamlInput, FluentIterable.from(cDepInput).transformAndConcat(a -> Arg.stringifyList(a, pathResolver)).toList(), input, isLibrary, isBytecode); }
From source file:org.lanternpowered.server.text.title.LanternTitles.java
private static CacheValue createValue(Title title) { final ImmutableList.Builder<Message> builder = ImmutableList.builder(); if (title.isClear()) { builder.add(new MessagePlayOutTitle.Clear()); }/*from w w w . ja va 2 s .co m*/ if (title.isReset()) { builder.add(new MessagePlayOutTitle.Reset()); } final Optional<Integer> fadeIn = title.getFadeIn(); final Optional<Integer> stay = title.getStay(); final Optional<Integer> fadeOut = title.getFadeOut(); if (fadeIn.isPresent() || stay.isPresent() || fadeOut.isPresent()) { builder.add(new MessagePlayOutTitle.SetTimes(fadeIn.orElse(20), stay.orElse(60), fadeOut.orElse(20))); } if (title.getTitle().isPresent() || title.getSubtitle().isPresent() || title.getActionBar().isPresent()) { return new LocaleCacheValue(builder.build(), title); } else { return new CacheValue(builder.build()); } }
From source file:com.opengamma.strata.calc.runner.function.result.ScenarioResult.java
/** * Obtains an instance using a function to create the entries. * <p>//from w ww . ja v a2s . c o m * The function is passed the scenario index and returns the value for that index. * * @param size the number of elements * @param valueFunction the function used to obtain each value * @return an instance initialized using the function * @throws IllegalArgumentException is size is zero or less */ public static <T> ScenarioResult<T> of(int size, IntFunction<T> valueFunction) { ArgChecker.notNegativeOrZero(size, "size"); ImmutableList.Builder<T> builder = ImmutableList.builder(); for (int i = 0; i < size; i++) { builder.add(valueFunction.apply(i)); } return ScenarioResult.of(builder.build()); }
From source file:uk.co.lucasweb.stream.ImmutableListCollector.java
@Override public Supplier<ImmutableList.Builder<E>> supplier() { return ImmutableList::builder; }
From source file:org.sonar.plugins.spcaf.spcafPluginAspx.java
/** * {@inheritDoc}/*from w w w . j a v a 2 s . co m*/ */ @Override public List getExtensions() { ImmutableList.Builder builder = ImmutableList.builder(); // Plugin properties and languages builder.add(PropertyDefinition.builder(ASPX_SUFFIXES_KEY).defaultValue(ASPX_SUFFIXES_DEFAULT_VALUE) .name("File Suffixes").description("Comma-separated list of suffixes for files to analyze.") .subCategory("General").onQualifiers(Qualifiers.PROJECT).build(), Aspx.class); return builder.build(); }
From source file:org.sonar.plugins.spcaf.spcafPluginPs1.java
/** * {@inheritDoc}/*from www . j a v a 2 s .c o m*/ */ @Override public List getExtensions() { ImmutableList.Builder builder = ImmutableList.builder(); // Plugin properties and languages builder.add(PropertyDefinition.builder(PS1_SUFFIXES_KEY).defaultValue(PS1_SUFFIXES_DEFAULT_VALUE) .name("File Suffixes").description("Comma-separated list of suffixes for files to analyze.") .subCategory("General").onQualifiers(Qualifiers.PROJECT).build(), Ps1.class); return builder.build(); }
From source file:com.stackframe.bentographer.BentoGrapher.java
private static Collection<Field> getFields(Connection connection, Library library) throws SQLException { ImmutableList.Builder<Field> fields = new ImmutableList.Builder(); PreparedStatement ps = connection.prepareStatement( "SELECT gn_label AS label, gn_name AS column, gn_typeName AS type FROM gn_field WHERE gn_domain=?"); try {// w w w . ja va 2 s .co m ps.setInt(1, library.domain); ResultSet rs = ps.executeQuery(); try { while (rs.next()) { String name = rs.getString("label"); String column = rs.getString("column"); String type = rs.getString("type"); fields.add(new Field(name, type, "gn_" + column)); } } finally { rs.close(); } } finally { ps.close(); } return fields.build(); }
From source file:fr.inria.eventcloud.api.Skolemizator.java
/** * Replaces blank nodes with IRIs within the specified collection of * {@link Quadruple}s. The transformation applied is the one described in * the last <a href=/* www . j av a2 s .c om*/ * "https://dvcs.w3.org/hg/rdf/raw-file/default/rdf-concepts/index.html#section-skolemization" * >RDF 1.1 draft</a>. * * @param quads * the quadruples to process. * * @return a collection of quadruples where Blank Nodes have been replaced * by IRIs. */ public static List<Quadruple> skolemize(Iterable<Quadruple> quads) { Builder<Quadruple> result = new ImmutableList.Builder<Quadruple>(); Map<Node, Node> assignedSkolems = new HashMap<Node, Node>(); for (Quadruple q : quads) { Node subject = q.getSubject(); Node object = q.getObject(); if (subject.isBlank() || object.isBlank()) { if (subject.isBlank()) { subject = getOrCreateSkolemUri(subject, assignedSkolems); } if (object.isBlank()) { object = getOrCreateSkolemUri(object, assignedSkolems); } result.add(new Quadruple(q.createMetaGraphNode(), subject, q.getPredicate(), object, false, true)); } else { result.add(q); } } return result.build(); }