List of usage examples for com.google.common.collect ImmutableList.Builder add
boolean add(E e);
From source file:com.google.api.codegen.config.PackagingConfig.java
@SuppressWarnings("unchecked") private static List<String> getProtoDeps(Map<String, Object> configMap, String key) { List<?> deps = (List<?>) configMap.get(key); if (deps == null || deps.size() == 0) { return ImmutableList.of(); }// w w w. jav a 2 s .c om if (deps.get(0) instanceof String) { // TODO delete this branch once artman always passes in the structure instead of just names return (List<String>) deps; } else { ImmutableList.Builder<String> depStrings = ImmutableList.builder(); for (Map<String, Object> packageData : (List<Map<String, Object>>) deps) { depStrings.add((String) packageData.get("name")); } return depStrings.build(); } }
From source file:cuchaz.m3l.event.handler.ListenerNodeList.java
private synchronized static void addToTracker(ListenerNodeList inst) { ImmutableList.Builder<ListenerNodeList> builder = ImmutableList.builder(); builder.addAll(listTracker);/*from ww w. ja va2 s . com*/ builder.add(inst); listTracker = builder.build(); }
From source file:com.google.devtools.build.android.desugar.scan.KeepScanner.java
/** * Transform a list of Path to a list of InputFileProvider and register them with the given * closer.//from w w w. ja v a 2 s. c o m */ @SuppressWarnings("MustBeClosedChecker") private static ImmutableList<InputFileProvider> toRegisteredInputFileProvider(Closer closer, List<Path> paths) throws IOException { ImmutableList.Builder<InputFileProvider> builder = new ImmutableList.Builder<>(); for (Path path : paths) { builder.add(closer.register(InputFileProvider.open(path))); } return builder.build(); }
From source file:com.spectralogic.ds3client.commands.GetObjectRequest.java
private static String buildRangeHeaderText(final ImmutableList<Range> byteRanges) { final ImmutableList.Builder<String> builder = ImmutableList.builder(); for (final Range range : byteRanges) { builder.add(String.format("%d-%d", range.getStart(), range.getEnd())); }/*w ww .java 2s . c om*/ final Joiner stringJoiner = Joiner.on(","); return "bytes=" + stringJoiner.join(builder.build()); }
From source file:blue.lapis.common.command.impl.Parsing.java
public static ImmutableList<String> split(String s, String delimiter) { ImmutableList.Builder<String> builder = ImmutableList.builder(); int tokenEnd = s.indexOf(delimiter); int loc = 0;//from w ww. j a v a 2 s . c om while (tokenEnd >= 0) { if (tokenEnd > loc) { builder.add(s.substring(loc, tokenEnd)); } loc = tokenEnd + delimiter.length(); tokenEnd = s.indexOf(delimiter, loc); } if (loc < s.length()) builder.add(s.substring(loc, s.length())); return builder.build(); }
From source file:com.android.build.gradle.internal.ProductFlavorCombo.java
/** * Remove all null reference from an array and create an ImmutableList it. *///w ww.j a v a 2s .c o m private static ImmutableList<ProductFlavor> filterNullFromArray(ProductFlavor[] flavors) { ImmutableList.Builder<ProductFlavor> builder = ImmutableList.builder(); for (ProductFlavor flavor : flavors) { if (flavor != null) { builder.add(flavor); } } return builder.build(); }
From source file:cz.cuni.mff.ms.brodecva.botnicek.ide.compile.library.Recursion.java
/** * Vrt tmata zajiujc: klid zsobnku po spnm prchodu v zanoen * st, nvrat do pvodn a pechod na dal stavy v zsobnku v ppad * nespchu./*from w w w . jav a 2 s . c o m*/ * * @param pullState * stav pro klid stav, kter jsme rozbalili, ale kvli spchu * je nen teba prochzet (umisuje se po oputn st clov * stavem) * @param pullStopState * zarka klidu (umisuje se po vejit do st vstupnm uzlem) * @param successState * stav indikujc spn projit podst, v ppad jinak * przdnho zsobnku pak celho systmu * @param failState * stav indikujc nespn ukon?en vpo?tu * @param returnState * stav uvozujc nvratov stav do st o rove ve pi * zanoen * @return knihovn tmata */ public static List<Topic> getLibrary(final NormalWord pullState, final NormalWord pullStopState, final NormalWord successState, final NormalWord failState, final NormalWord returnState) { Preconditions.checkNotNull(pullState); Preconditions.checkNotNull(pullStopState); Preconditions.checkNotNull(failState); Preconditions.checkNotNull(returnState); final String star = AIML.STAR_WILDCARD.getValue(); final String space = AIML.WORD_DELIMITER.getValue(); final String pull = pullState.getText(); final String pullStop = pullStopState.getText(); final String reTurn = returnState.getText(); final String success = successState.getText(); final String fail = failState.getText(); final Index two = new AIMLIndex(2); final ImmutableList.Builder<Topic> topics = ImmutableList.builder(); // @formatter:off // PULL * PULLSTOP * -> PULL PULLSTOP * topics.add(Topic.create(Patterns.create(join(pull, star, pullStop, star)), Category.createUniversal( Template.create(Stack.set(Text.create(join(pull, pullStop) + space), Topicstar.create(two)), Sr.create())))); // PULL PULLSTOP RETURN * -> SUCCESS * topics.add(Topic.create(Patterns.create(join(pull, pullStop, reTurn, star)), Category.createUniversal(Template.create(Stack.popAndPushWords(successState), Sr.create())))); // PULL PULLSTOP * -> * topics.add(Topic.create(Patterns.create(join(pull, pullStop, star)), Category.createUniversal(Template.create(Stack.pop(), Sr.create())))); // PULL PULLSTOP -> SUCCESS topics.add(Topic.create(Patterns.create(join(pull, pullStop)), Category.createUniversal(Template.create(Stack.set(Text.create(success)), Sr.create())))); // PULLSTOP RETURN * * -> 2nd* topics.add(Topic.create(Patterns.create(join(pullStop, reTurn, star, star)), Category.createUniversal(Template.create(Stack.set(Topicstar.create(two)), Sr.create())))); // PULLSTOP * -> * topics.add(Topic.create(Patterns.create(join(pullStop, star)), Category.createUniversal(Template.create(Stack.pop(), Sr.create())))); // PULLSTOP -> FAIL topics.add(Topic.create(Patterns.create(pullStop), Category.createUniversal(Template.create(Stack.set(Text.create(fail)), Sr.create())))); // SUCCESS topics.add(Topic.create(Patterns.create(success), Category.createUniversal(Template.create()))); // @formatter:on return topics.build(); }
From source file:org.apache.calcite.rel.RelCollations.java
public static RelCollation shift(RelCollation collation, int offset) { if (offset == 0) { return collation; // save some effort }/*w ww.j a va 2 s . co m*/ final ImmutableList.Builder<RelFieldCollation> fieldCollations = ImmutableList.builder(); for (RelFieldCollation fc : collation.getFieldCollations()) { fieldCollations.add(fc.shift(offset)); } return new RelCollationImpl(fieldCollations.build()); }
From source file:be.nbb.demetra.dotstat.DotStatAccessor.java
private static List<DbSetId> getAllSeries(SdmxConnection conn, FlowRef flowRef, DbSetId ref) throws IOException { Converter<DbSetId, Key> converter = getConverter(conn.getDataStructure(flowRef), ref); Key colKey = converter.convert(ref); try (TsCursor<Key, IOException> cursor = DotStatUtil.getAllSeries(conn, flowRef, colKey)) { ImmutableList.Builder<DbSetId> result = ImmutableList.builder(); while (cursor.nextSeries()) { result.add(converter.reverse().convert(cursor.getKey())); }// w ww.jav a 2s .co m return result.build(); } }
From source file:google.registry.util.CollectionUtils.java
/** Partitions a Map into a Collection of Maps, each of max size n. */ public static <K, V> ImmutableList<ImmutableMap<K, V>> partitionMap(Map<K, V> map, int size) { ImmutableList.Builder<ImmutableMap<K, V>> shards = new ImmutableList.Builder<>(); for (Iterable<Map.Entry<K, V>> entriesShard : partition(map.entrySet(), size)) { shards.add(ImmutableMap.copyOf(entriesShard)); }/*from w w w .j av a 2s . c o m*/ return shards.build(); }