Example usage for com.google.common.collect ImmutableList.Builder add

List of usage examples for com.google.common.collect ImmutableList.Builder add

Introduction

In this page you can find the example usage for com.google.common.collect ImmutableList.Builder add.

Prototype

boolean add(E e);

Source Link

Document

Appends the specified element to the end of this list (optional operation).

Usage

From source file:org.apache.tajo.catalog.TypeConverter.java

public static Type convert(TypeDesc type) {
    if (type.getDataType().getType() == TajoDataTypes.Type.RECORD) {
        ImmutableList.Builder<Field> fields = ImmutableList.builder();
        for (Column c : type.getNestedSchema().getRootColumns()) {
            fields.add(FieldConverter.convert(c));
        }//from  w w w. j  ava  2s  . c om
        return Record(fields.build());
    } else {
        return convert(type.dataType);
    }
}

From source file:com.facebook.presto.server.QueryResource.java

private static List<BasicQueryInfo> extractBasicQueryInfo(List<QueryInfo> allQueryInfo) {
    ImmutableList.Builder<BasicQueryInfo> basicQueryInfo = ImmutableList.builder();
    for (QueryInfo queryInfo : allQueryInfo) {
        basicQueryInfo.add(new BasicQueryInfo(queryInfo));
    }/*from ww w.j a  v  a  2s  .c  o m*/
    return basicQueryInfo.build();
}

From source file:com.spectralogic.ds3autogen.java.utils.CommonRequestGeneratorUtils.java

/**
 * Creates a constructor with the provided parameters in addition to
 * adding the required parameter Stream for parsing a request payload.
 *//*from   w  w w .jav  a 2  s  .c o  m*/
public static RequestConstructor createInputStreamConstructor(final ImmutableList<Arguments> parameters,
        final ImmutableList<QueryParam> queryParams, final String requestName, final Ds3DocSpec docSpec) {
    final ImmutableList.Builder<Arguments> builder = ImmutableList.builder();
    if (hasContent(parameters)) {
        builder.addAll(parameters);
    }
    builder.add(new Arguments("InputStream", "Stream"));

    final ImmutableList<Arguments> updatedParameters = builder.build();
    final ImmutableList<String> argNames = updatedParameters.stream().map(Arguments::getName)
            .collect(GuavaCollectors.immutableList());

    return new RequestConstructor(updatedParameters, updatedParameters, queryParams,
            toConstructorDocs(requestName, argNames, docSpec, 1));
}

From source file:com.facebook.buck.cxx.elf.ElfDynamicSection.java

public static ElfDynamicSection parse(ElfHeader.EIClass eiClass, ByteBuffer buffer) {
    ImmutableList.Builder<Entry> entries = ImmutableList.builder();
    while (buffer.hasRemaining()) {
        entries.add(Entry.parse(eiClass, buffer));
    }/*from www  . j a va 2  s. c o  m*/
    return new ElfDynamicSection(entries.build());
}

From source file:com.google.devtools.build.lib.skylarkdebug.server.DebuggerSerialization.java

private static ImmutableList<Value> getChildren(Iterable<?> iterable) {
    ImmutableList.Builder<Value> builder = ImmutableList.builder();
    int index = 0;
    for (Object value : iterable) {
        builder.add(getValueProto(String.format("[%d]", index++), value));
    }/*from w ww.ja v a2  s  .co m*/
    return builder.build();
}

From source file:org.apache.abdera2.activities.io.gson.MultimapAdapter.java

protected static ImmutableList<Object> arraydes(JsonArray array, JsonDeserializationContext context) {
    ImmutableList.Builder<Object> builder = ImmutableList.builder();
    for (JsonElement child : array)
        if (child.isJsonArray())
            builder.add(arraydes(child.getAsJsonArray(), context));
        else if (child.isJsonObject())
            builder.add(context.deserialize(child, ASBase.class));
        else if (child.isJsonPrimitive())
            builder.add(primdes(child.getAsJsonPrimitive()));
    return builder.build();
}

From source file:com.google.devtools.build.lib.syntax.BuiltinCallable.java

private static List<ExtraArgKind> getExtraArgs(SkylarkCallable annotation) {
    ImmutableList.Builder<ExtraArgKind> extraArgs = ImmutableList.builder();
    if (annotation.useLocation()) {
        extraArgs.add(ExtraArgKind.LOCATION);
    }/*from  w  ww .j ava 2  s.  c o m*/
    if (annotation.useAst()) {
        extraArgs.add(ExtraArgKind.SYNTAX_TREE);
    }
    if (annotation.useEnvironment()) {
        extraArgs.add(ExtraArgKind.ENVIRONMENT);
    }
    if (annotation.useSkylarkSemantics()) {
        extraArgs.add(ExtraArgKind.SEMANTICS);
    }
    return extraArgs.build();
}

From source file:org.apache.beam.sdk.values.reflect.DefaultRowTypeFactory.java

private static List<Coder> getFieldCoders(Iterable<FieldValueGetter> fieldValueGetters) {
    ImmutableList.Builder<Coder> coders = ImmutableList.builder();

    for (FieldValueGetter fieldValueGetter : fieldValueGetters) {
        try {//from  w w  w. j av  a2s  . c o  m
            coders.add(CODER_REGISTRY.getCoder(fieldValueGetter.type()));
        } catch (CannotProvideCoderException e) {
            throw new UnsupportedOperationException(
                    "Fields of type " + fieldValueGetter.type().getSimpleName() + " are not supported yet", e);
        }
    }

    return coders.build();
}

From source file:com.spectralogic.dsbrowser.gui.services.ds3Panel.CreateService.java

public static void createFolderPrompt(final Ds3Common ds3Common, final LoggingService loggingService,
        final ResourceBundle resourceBundle) {
    ImmutableList<TreeItem<Ds3TreeTableValue>> values = ds3Common.getDs3TreeTableView().getSelectionModel()
            .getSelectedItems().stream().collect(GuavaCollectors.immutableList());
    final TreeItem<Ds3TreeTableValue> root = ds3Common.getDs3TreeTableView().getRoot();
    final LazyAlert alert = new LazyAlert(resourceBundle);

    if (values.stream().map(TreeItem::getValue).anyMatch(Ds3TreeTableValue::isSearchOn)) {
        LOG.info("You can not create folder here. Please refresh your view");
        alert.info("cantCreateFolderHere");
        return;/*from  w ww . j  av  a2  s  .c  o  m*/
    } else if (values.isEmpty() && root != null && root.getValue() != null) {
        final ImmutableList.Builder<TreeItem<Ds3TreeTableValue>> builder = ImmutableList.builder();
        values = builder.add(root).build();
    } else if (values.isEmpty()) {
        loggingService.logMessage(resourceBundle.getString("selectLocation"), LogType.ERROR);
        alert.info("locationNotSelected");
        return;
    } else if (values.size() > 1) {
        LOG.info("Only a single location can be selected to create empty folder");
        alert.info("selectSingleLocation");
        return;
    }

    final Optional<TreeItem<Ds3TreeTableValue>> first = values.stream().findFirst();
    if (first.isPresent()) {
        final TreeItem<Ds3TreeTableValue> ds3TreeTableValueTreeItem = first.get();

        final String destinationDirectory = ds3TreeTableValueTreeItem.getValue().getDirectoryName();

        final ImmutableList<String> buckets = values.stream().map(TreeItem::getValue)
                .map(Ds3TreeTableValue::getBucketName).distinct().collect(GuavaCollectors.immutableList());
        final Optional<String> bucketElement = buckets.stream().findFirst();
        bucketElement.ifPresent(bucket -> CreateFolderPopup.show(
                new CreateFolderModel(ds3Common.getCurrentSession().getClient(), destinationDirectory, bucket),
                resourceBundle));

        Ds3PanelService.refresh(ds3TreeTableValueTreeItem);
    }
}

From source file:co.cask.cdap.data2.dataset2.lib.table.hbase.HBaseOrderedTableAdmin.java

public static CoprocessorJar createCoprocessorJarInternal(CConfiguration conf, LocationFactory locationFactory,
        HBaseTableUtil tableUtil, boolean supportsReadlessIncrement) throws IOException {
    if (!conf.getBoolean(TxConstants.DataJanitor.CFG_TX_JANITOR_ENABLE,
            TxConstants.DataJanitor.DEFAULT_TX_JANITOR_ENABLE)) {
        return CoprocessorJar.EMPTY;
    }//  w w  w .  ja  v a 2s.  c o m

    // create the jar for the data janitor coprocessor.
    Location jarDir = locationFactory.create(conf.get(Constants.CFG_HDFS_LIB_DIR));
    Class<? extends Coprocessor> dataJanitorClass = tableUtil.getTransactionDataJanitorClassForVersion();
    Class<? extends Coprocessor> incrementClass = tableUtil.getIncrementHandlerClassForVersion();
    ImmutableList.Builder<Class<? extends Coprocessor>> coprocessors = ImmutableList.builder();
    coprocessors.add(dataJanitorClass);
    if (supportsReadlessIncrement) {
        coprocessors.add(incrementClass);
    }
    ImmutableList<Class<? extends Coprocessor>> coprocessorList = coprocessors.build();
    Location jarFile = HBaseTableUtil.createCoProcessorJar("table", jarDir, coprocessorList);
    return new CoprocessorJar(coprocessorList, jarFile);
}