List of usage examples for com.google.common.collect ImmutableList.Builder add
boolean add(E e);
From source file:com.google.copybara.transform.Sequence.java
/** * Create a sequence from a list of native and Skylark transforms. * @param description a description of the argument being converted, such as its name * @param env skylark environment for user defined transformations */// ww w.j a v a2s . co m public static Sequence fromConfig(SkylarkList<?> elements, String description, Environment env) throws EvalException { ImmutableList.Builder<Transformation> transformations = ImmutableList.builder(); for (Object element : elements) { transformations.add(convertToTransformation(description, env, element)); } return new Sequence(transformations.build()); }
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)); }/* w w w. j a va 2 s . com*/ } messages.add( new Message(Message.Kind.ERROR, DUPLICATE_RESOURCES, DUPLICATE_RESOURCES, positions.build())); } return Iterables.toArray(messages, Message.class); }
From source file:org.thiesen.ttbin.TTBinEntries.java
public static TTBinEntries read(final InputStream in) throws IOException { Preconditions.checkNotNull(in, "InputStream is null"); final ImmutableList.Builder<TTBinEntry> entryListBuilder = ImmutableList.builder(); byte tag = readOneByte(in); while (tag != -1) { entryListBuilder.add(TTBinEntryReader.handlerFor(tag).read(in)); tag = readOneByte(in);//w ww.j a v a 2s. com } return new TTBinEntries(entryListBuilder.build()); }
From source file:ec.tss.tsproviders.db.DbUtil.java
@Nonnull public static <T extends Exception> List<String> getChildren(@Nonnull ChildrenCursor<T> cursor) throws T { ImmutableList.Builder<String> result = ImmutableList.builder(); while (cursor.next()) { result.add(cursor.child); }/* ww w. ja v a 2 s. c o m*/ return result.build(); }
From source file:ch.ethz.system.mt.tpch.GenerateUtils.java
private static List<String> makeDateStringIndex() { ImmutableList.Builder<String> dates = ImmutableList.builder(); for (int i = 0; i < TOTAL_DATE_RANGE; i++) { dates.add(makeDate(i + 1)); }/*from w ww . j ava 2 s . c om*/ return dates.build(); }
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.j a 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.spectralogic.ds3autogen.utils.ArgumentsUtil.java
/** * Changes the type of all arguments with the specified type *///from w w w. ja va 2 s .co m public static ImmutableList<Arguments> modifyType(final ImmutableList<Arguments> args, final String curType, final String newType) { if (isEmpty(args)) { return ImmutableList.of(); } final ImmutableList.Builder<Arguments> builder = ImmutableList.builder(); for (final Arguments arg : args) { if (arg.getType().equals(curType)) { builder.add(new Arguments(newType, arg.getName())); } else { builder.add(arg); } } return builder.build(); }
From source file:com.facebook.presto.type.FunctionType.java
private static TypeSignature[] typeParameters(List<Type> argumentTypes, Type returnType) { requireNonNull(returnType, "returnType is null"); requireNonNull(argumentTypes, "argumentTypes is null"); ImmutableList.Builder<TypeSignature> builder = ImmutableList.builder(); argumentTypes.stream().map(Type::getTypeSignature).forEach(builder::add); builder.add(returnType.getTypeSignature()); List<TypeSignature> signatures = builder.build(); return signatures.toArray(new TypeSignature[signatures.size()]); }
From source file:ec.tss.tsproviders.db.DbUtil.java
@Nonnull public static <T extends Exception> List<DbSetId> getAllSeries(@Nonnull AllSeriesCursor<T> cursor, @Nonnull DbSetId ref) throws T { ImmutableList.Builder<DbSetId> result = ImmutableList.builder(); while (cursor.next()) { result.add(ref.child(cursor.dimValues)); }/*from w ww .j a va 2 s .com*/ return result.build(); }
From source file:google.registry.model.index.EppResourceIndexBucket.java
/** Returns the keys to all buckets. */ public static Iterable<Key<EppResourceIndexBucket>> getAllBuckets() { ImmutableList.Builder<Key<EppResourceIndexBucket>> builder = new ImmutableList.Builder<>(); for (int bucketId = 1; bucketId <= getEppResourceIndexBucketCount(); bucketId++) { builder.add(getBucketKey(bucketId)); }/*from w ww . j a v a 2s.c om*/ return builder.build(); }