List of usage examples for com.google.common.collect ImmutableList builder
public static <E> Builder<E> builder()
From source file:org.obiba.magma.datasource.mongodb.converter.ValueConverter.java
public static Value unmarshall(ValueType type, boolean repeatable, String field, BSONObject object) { if (object == null || !object.containsField(field)) { return repeatable ? type.nullSequence() : type.nullValue(); }//w w w .j a va 2 s .co m if (repeatable) { Iterable<?> values = (Iterable<?>) object.get(field); if (values == null) return type.nullSequence(); ImmutableList.Builder<Value> list = ImmutableList.builder(); for (Object o : values) { list.add(unmarshall(type, o)); } return type.sequenceOf(list.build()); } return unmarshall(type, object.get(field)); }
From source file:com.spectralogic.ds3autogen.converters.RemoveDollarSignConverter.java
/** * Removes all instances of '$' from type names within a Ds3Request */// w ww . j a v a 2 s . com protected static ImmutableList<Ds3Request> removeDollarSignFromAllRequests( final ImmutableList<Ds3Request> requests) { if (isEmpty(requests)) { return ImmutableList.of(); } final ImmutableList.Builder<Ds3Request> builder = ImmutableList.builder(); for (final Ds3Request request : requests) { builder.add(removeDollarSignFromRequest(request)); } return builder.build(); }
From source file:eu.eidas.auth.commons.attribute.FileAttributeDefinitionDao.java
private static ImmutableList<SingletonAccessor<ImmutableSortedSet<AttributeDefinition<?>>>> newSingletonAccessors( @Nonnull String fileName, @Nonnull String[] fileNames) { ImmutableList.Builder<SingletonAccessor<ImmutableSortedSet<AttributeDefinition<?>>>> builder = new ImmutableList.Builder<>(); Set<String> duplicates = new HashSet<>(); duplicates.add(fileName);/*from w w w . j a va 2 s .c om*/ builder.add(newSingletonAccessor(fileName)); for (final String name : fileNames) { if (duplicates.add(name)) { builder.add(newSingletonAccessor(name)); } } return builder.build(); }
From source file:com.github.hilcode.versionator.Zipper.java
@Override public Iterator<Tuple._2<T, T>> iterator() { final ImmutableList.Builder<Tuple._2<T, T>> zipper = ImmutableList.builder(); final Iterator<T> as = this.a.iterator(); final Iterator<T> bs = this.b.iterator(); while (as.hasNext() && bs.hasNext()) { final Tuple._2<T, T> tuple = new Tuple._2<>(as.next(), bs.next()); zipper.add(tuple);/* ww w . ja v a2 s. c o m*/ } return zipper.build().iterator(); }
From source file:com.android.tools.idea.tests.gui.framework.fixture.LayoutInspectorFixture.java
@NotNull public ImmutableList<String> getLayoutElements() { ImmutableList.Builder<String> builder = new ImmutableList.Builder<>(); JTree tree = myRobot.finder().findByType(myTarget, RollOverTree.class, true); JTreeFixture treeFixture = new JTreeFixture(myRobot, tree); for (int i = 0; i < tree.getRowCount(); i++) { String element = treeFixture.valueAt(i); builder.add(element.substring(0, element.indexOf("@")).trim()); }/*from w w w . j a va2s . c o m*/ return builder.build(); }
From source file:com.android.utils.StringHelper.java
/** * Returns a list of Strings containing the objects passed in argument. * * If the objects are strings, they are directly added to the list. * If the objects are collections of strings, the strings are added. * For other objects, the result of their toString() is added. * @param objects the objects to add/*from w ww . ja v a 2s . c o m*/ * @return the list of objects. */ @NonNull public static List<String> toStrings(@NonNull Object... objects) { ImmutableList.Builder<String> builder = ImmutableList.builder(); for (Object path : objects) { if (path instanceof String) { builder.add((String) path); } else if (path instanceof Collection) { Collection pathCollection = (Collection) path; for (Object item : pathCollection) { if (item instanceof String) { builder.add((String) item); } else { builder.add(path.toString()); } } } else { builder.add(path.toString()); } } return builder.build(); }
From source file:flipkart.mongo.replicator.core.versions.VersionManager.java
protected VersionManager() { Reflections reflections = new Reflections("flipkart.mongo.replicator.core.versions"); Set<Class<? extends VersionHandler>> classes = reflections.getSubTypesOf(VersionHandler.class); ImmutableList.Builder<VersionHandler> builder = new ImmutableList.Builder<VersionHandler>(); for (Class<? extends VersionHandler> clazz : classes) { try {//from w w w. j a v a 2 s .co m builder.add(clazz.newInstance()); } catch (Exception e) { } } versionHandlers = builder.build(); }
From source file:org.smartdeveloperhub.vocabulary.util.Serializations.java
public static List<Path> generate(final Catalog catalog, final Path where) throws IOException { final SerializationManager manager = SerializationManager.create(catalog, where); final Builder<Path> builder = ImmutableList.builder(); for (final String moduleId : catalog.modules()) { collectModuleSerializations(builder, manager, catalog.get(moduleId)); }/* w w w . j av a2 s .c o m*/ return builder.build(); }
From source file:org.locationtech.geogig.plumbing.CleanRefsOp.java
@Override protected ImmutableList<String> _call() { Builder<String> cleaned = new ImmutableList.Builder<String>(); Optional<Ref> ref = command(RefParse.class).setName(Ref.MERGE_HEAD).call(); if (ref.isPresent()) { cleaned.add(Ref.MERGE_HEAD); command(UpdateRef.class).setDelete(true).setName(Ref.MERGE_HEAD).call(); }//from w w w. j a v a 2 s .com ref = command(RefParse.class).setName(Ref.ORIG_HEAD).call(); if (ref.isPresent()) { cleaned.add(Ref.ORIG_HEAD); command(UpdateRef.class).setDelete(true).setName(Ref.ORIG_HEAD).call(); } ref = command(RefParse.class).setName(Ref.CHERRY_PICK_HEAD).call(); if (ref.isPresent()) { cleaned.add(Ref.CHERRY_PICK_HEAD); command(UpdateRef.class).setDelete(true).setName(Ref.CHERRY_PICK_HEAD).call(); } BlobStore blobStore = context.blobStore(); Optional<String> blob = Blobs.getBlobAsString(blobStore, MergeOp.MERGE_MSG); if (blob.isPresent()) { cleaned.add(MergeOp.MERGE_MSG); blobStore.removeBlob(MergeOp.MERGE_MSG); } return cleaned.build(); }
From source file:vazkii.botania.client.integration.jei.manapool.ManaPoolRecipeWrapper.java
public ManaPoolRecipeWrapper(RecipeManaInfusion recipe) { ImmutableList.Builder<Object> builder = ImmutableList.builder(); if (recipe.getInput() instanceof ItemStack) { builder.add(recipe.getInput());/*from w ww . j a v a 2 s.co m*/ } else if (recipe.getInput() instanceof String) { builder.add(OreDictionary.getOres((String) recipe.getInput())); } if (recipe.getCatalyst() != null) { Block block = recipe.getCatalyst().getBlock(); if (Item.getItemFromBlock(block) != null) { builder.add(new ItemStack(block, 1, block.getMetaFromState(recipe.getCatalyst()))); } } input = builder.build(); output = recipe.getOutput(); mana = recipe.getManaToConsume(); }