当前位置: 首页>>代码示例>>Java>>正文


Java ImmutableList.Builder方法代码示例

本文整理汇总了Java中com.google.common.collect.ImmutableList.Builder方法的典型用法代码示例。如果您正苦于以下问题:Java ImmutableList.Builder方法的具体用法?Java ImmutableList.Builder怎么用?Java ImmutableList.Builder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.common.collect.ImmutableList的用法示例。


在下文中一共展示了ImmutableList.Builder方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: TemplateVars

import com.google.common.collect.ImmutableList; //导入方法依赖的package包/类
TemplateVars() {
    if (getClass().getSuperclass() != TemplateVars.class) {
        throw new IllegalArgumentException("Class must extend TemplateVars directly");
    }
    ImmutableList.Builder<Field> fields = ImmutableList.builder();
    Field[] declaredFields = getClass().getDeclaredFields();
    for (Field field : declaredFields) {
        if (field.isSynthetic() || isStaticFinal(field)) {
            continue;
        }
        if (Modifier.isPrivate(field.getModifiers())) {
            throw new IllegalArgumentException("Field cannot be private: " + field);
        }
        if (Modifier.isStatic(field.getModifiers())) {
            throw new IllegalArgumentException("Field cannot be static unless also final: " + field);
        }
        if (field.getType().isPrimitive()) {
            throw new IllegalArgumentException("Field cannot be primitive: " + field);
        }
        fields.add(field);
    }
    this.fields = fields.build();
}
 
开发者ID:sopak,项目名称:auto-value-step-builder,代码行数:24,代码来源:TemplateVars.java

示例2: buildMethods

import com.google.common.collect.ImmutableList; //导入方法依赖的package包/类
@Nonnull
@Override
protected List<MethodSpec> buildMethods() {
    final MethodSpec.Builder constructorBuilder = MethodSpec.constructorBuilder()
            .addModifiers(Modifier.PUBLIC);

    final ImmutableList.Builder<MethodSpec> builder = ImmutableList.builder();
    getProperties().entrySet().forEach(property -> {
        final String name = property.getKey();
        final TypeName type = property.getValue();
        final String fieldName = fieldNamePolicy.convert(name, type);
        final String methodName = methodNamePolicy.convert(name, type);
        builder.add(MethodSpec.methodBuilder(methodName)
                .addModifiers(Modifier.PUBLIC)
                .returns(type)
                .addStatement("return $L", fieldName)
                .build());

        final String propertyName = parameterNamePolicy.convert(name, type);
        constructorBuilder.addParameter(ParameterSpec.builder(type, propertyName)
                .build())
                .addStatement("this.$L = $L", fieldName, propertyName);
    });
    builder.add(constructorBuilder.build());
    return builder.build();
}
 
开发者ID:t28hub,项目名称:json2java4idea,代码行数:27,代码来源:MoshiClassBuilder.java

示例3: getVisibleMethods

import com.google.common.collect.ImmutableList; //导入方法依赖的package包/类
private ImmutableList<Method> getVisibleMethods(Class<?> cls) {
  // Don't use cls.getPackage() because it does nasty things like reading
  // a file.
  String visiblePackage = Reflection.getPackageName(cls);
  ImmutableList.Builder<Method> builder = ImmutableList.builder();
  for (Class<?> type : TypeToken.of(cls).getTypes().rawTypes()) {
    if (!Reflection.getPackageName(type).equals(visiblePackage)) {
      break;
    }
    for (Method method : type.getDeclaredMethods()) {
      if (!method.isSynthetic() && isVisible(method)) {
        builder.add(method);
      }
    }
  }
  return builder.build();
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:18,代码来源:NullPointerTester.java

示例4: visitSimpleCaseExpression

import com.google.common.collect.ImmutableList; //导入方法依赖的package包/类
@Override
protected String visitSimpleCaseExpression(SimpleCaseExpression node, StackableAstVisitorContext<Integer> indent)
{
    ImmutableList.Builder<String> parts = ImmutableList.builder();

    parts.add("CASE")
            .add(process(node.getOperand(), indent));

    for (WhenClause whenClause : node.getWhenClauses()) {
        parts.add(process(whenClause, indent));
    }

    node.getDefaultValue()
            .ifPresent((value) -> parts.add("ELSE").add(process(value, indent)));

    parts.add("END");

    return "(" + Joiner.on(' ').join(parts.build()) + ")";
}
 
开发者ID:prestodb-rocks,项目名称:presto-query-formatter,代码行数:20,代码来源:ExpressionFormatter.java

示例5: visitList

import com.google.common.collect.ImmutableList; //导入方法依赖的package包/类
protected List<RexNode> visitList(
    List<? extends RexNode> exprs, boolean[] update, LevelHolder output) {
  ImmutableList.Builder<RexNode> clonedOperands = ImmutableList.builder();
  int level = 0;
  for (RexNode operand : exprs) {
    LevelHolder cnt = new LevelHolder();
    RexNode clonedOperand = operand.accept(this, cnt);
    if ((clonedOperand != operand) && (update != null)) {
      update[0] = true;
    }
    level = Math.max(cnt.index, level);
    clonedOperands.add(clonedOperand);
  }
  output.index = level;
  return clonedOperands.build();
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:17,代码来源:RewriteProjectToFlattenRule.java

示例6: visitSimpleCaseExpression

import com.google.common.collect.ImmutableList; //导入方法依赖的package包/类
@Override
protected String visitSimpleCaseExpression(SimpleCaseExpression node, Void context)
{
    ImmutableList.Builder<String> parts = ImmutableList.builder();

    parts.add("CASE")
            .add(process(node.getOperand(), context));

    for (WhenClause whenClause : node.getWhenClauses()) {
        parts.add(process(whenClause, context));
    }
    if (node.getDefaultValue() != null) {
        parts.add("ELSE")
                .add(process(node.getDefaultValue(), context));
    }
    parts.add("END");

    return "(" + WHITESPACE_JOINER.join(parts.build()) + ")";
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:20,代码来源:ExpressionFormatter.java

示例7: updateProjectInfo

import com.google.common.collect.ImmutableList; //导入方法依赖的package包/类
private CompletionStage<ProjectInfo> updateProjectInfo(Author author, String commitSummary,
                                                       List<ProjectInfo> list, String projectName,
                                                       Function<ProjectInfo, ProjectInfo> updater,
                                                       boolean forceUpdate) {
    final ImmutableList.Builder<ProjectInfo> newList = ImmutableList.builder();
    ProjectInfo target = null;
    for (ProjectInfo p : list) {
        if ((forceUpdate || !p.isRemoved()) && p.name().equals(projectName)) {
            p = updater.apply(p);
            if (target != null) {
                throw new IllegalStateException("Project '" + projectName + "' is not unique.");
            }
            target = p;
        }
        newList.add(p);
    }
    if (target == null) {
        throw new ProjectNotFoundException(projectName);
    }

    final ProjectInfo ret = target;
    final Change<JsonNode> change = Change.ofJsonPatch(METADATA_JSON,
                                                       Jackson.valueToTree(list),
                                                       Jackson.valueToTree(newList.build()));
    return pushChanges(change, author, commitSummary)
            .thenApply(unused -> ret);
}
 
开发者ID:line,项目名称:centraldogma,代码行数:28,代码来源:MetadataService.java

示例8: getSupportedConvertOps

import com.google.common.collect.ImmutableList; //导入方法依赖的package包/类
private static final Iterable<ConvertSupport> getSupportedConvertOps() {
  // A set would be more appropriate but it's not possible to produce
  // duplicates, and an iterable is all we need.
  ImmutableList.Builder<ConvertSupport> supportedConvertedOps = ImmutableList.builder();

  for(MinorType from: MinorType.values()) {
    for(MinorType to: MinorType.values()) {
      if (TypeCastRules.isCastable(from, to)) {
        supportedConvertedOps.add(ConvertSupport.newBuilder().setFrom(from).setTo(to).build());
      }
    }
  }

  return supportedConvertedOps.build();
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:16,代码来源:ServerMetaProvider.java

示例9: HDFSPageSource

import com.google.common.collect.ImmutableList; //导入方法依赖的package包/类
public HDFSPageSource(
        ParquetReader parquetReader,
        ParquetDataSource dataSource,
        MessageType fileSchema,
        MessageType requestedSchema,
        long totalBytes,
        List<HDFSColumnHandle> columns,
        TypeManager typeManager)
{
    checkArgument(totalBytes >= 0, "totalBytes is negative");

    this.parquetReader = requireNonNull(parquetReader, "parquetReader is null");
    this.dataSource = requireNonNull(dataSource, "dataSource is null");
    this.fileSchema = requireNonNull(fileSchema, "fileSchema is null");
    this.requestedSchema = requireNonNull(requestedSchema, "requestedSchema is null");
    this.totalBytes = totalBytes;

    this.columnSize = columns.size();
    this.constantBlocks = new Block[columnSize];
    ImmutableList.Builder<String> namesBuilder = ImmutableList.builder();
    ImmutableList.Builder<Type> typesBuilder = ImmutableList.builder();
    for (int columnIndex = 0; columnIndex < columnSize; columnIndex++) {
        HDFSColumnHandle column = columns.get(columnIndex);
        String name = column.getName();
        Type type = typeManager.getType(column.getType().getTypeSignature());

        namesBuilder.add(name);
        typesBuilder.add(type);

        if (getParquetType(column, fileSchema) == null) {
            constantBlocks[columnIndex] = RunLengthEncodedBlock.create(type, null, MAX_VECTOR_LENGTH);
        }
    }
    columnNames = namesBuilder.build();
    types = typesBuilder.build();
}
 
开发者ID:dbiir,项目名称:paraflow,代码行数:37,代码来源:HDFSPageSource.java

示例10: visitArrayConstructor

import com.google.common.collect.ImmutableList; //导入方法依赖的package包/类
@Override
protected String visitArrayConstructor(ArrayConstructor node, StackableAstVisitorContext<Integer> indent)
{
    ImmutableList.Builder<String> valueStrings = ImmutableList.builder();
    for (Expression value : node.getValues()) {
        valueStrings.add(formatExpression(value, parameters, indent.getContext() + 1));
    }
    return "ARRAY[" + Joiner.on(",").join(valueStrings.build()) + "]";
}
 
开发者ID:prestodb-rocks,项目名称:presto-query-formatter,代码行数:10,代码来源:ExpressionFormatter.java

示例11: listOperations

import com.google.common.collect.ImmutableList; //导入方法依赖的package包/类
@Override
public void listOperations(
    ListOperationsRequest request,
    StreamObserver<ListOperationsResponse> responseObserver) {
  Instance instance;
  try {
    instance = instances.getFromOperationsCollectionName(
        request.getName());
  } catch (InstanceNotFoundException ex) {
    responseObserver.onError(BuildFarmInstances.toStatusException(ex));
    return;
  }

  int pageSize = request.getPageSize();
  if (pageSize < 0) {
    responseObserver.onError(new StatusException(Status.OUT_OF_RANGE));
    return;
  }

  ImmutableList.Builder<Operation> operations =
      new ImmutableList.Builder<Operation>();

  String nextPageToken = instance.listOperations(
      pageSize,
      request.getPageToken(),
      request.getFilter(),
      operations);

  responseObserver.onNext(ListOperationsResponse.newBuilder()
      .addAllOperations(operations.build())
      .setNextPageToken(nextPageToken)
      .build());
  responseObserver.onCompleted();
}
 
开发者ID:bazelbuild,项目名称:bazel-buildfarm,代码行数:35,代码来源:OperationsService.java

示例12: visitArrayConstructor

import com.google.common.collect.ImmutableList; //导入方法依赖的package包/类
@Override
protected String visitArrayConstructor(ArrayConstructor node, Void context)
{
    ImmutableList.Builder<String> valueStrings = ImmutableList.builder();
    for (Expression value : node.getValues()) {
        valueStrings.add(SqlFormatter.formatSql(value, parameters));
    }
    return "ARRAY[" + Joiner.on(",").join(valueStrings.build()) + "]";
}
 
开发者ID:dbiir,项目名称:rainbow,代码行数:10,代码来源:ExpressionFormatter.java

示例13: getTree

import com.google.common.collect.ImmutableList; //导入方法依赖的package包/类
@Override
public String getTree(
    Digest rootDigest, int pageSize, String pageToken,
    ImmutableList.Builder<Directory> directories) {
  if (pageSize == 0) {
    pageSize = getTreeDefaultPageSize();
  }
  if (pageSize >= 0 && pageSize > getTreeMaxPageSize()) {
    pageSize = getTreeMaxPageSize();
  }

  TokenizableIterator<Directory> iter =
    createTreeIterator(rootDigest, pageToken);

  while (iter.hasNext() && pageSize != 0) {
    Directory directory = iter.next();
    // If part of the tree is missing from the CAS, the server will return the
    // portion present and omit the rest.
    if (directory != null) {
      directories.add(directory);
      if (pageSize > 0) {
        pageSize--;
      }
    }
  }
  return iter.toNextPageToken();
}
 
开发者ID:bazelbuild,项目名称:bazel-buildfarm,代码行数:28,代码来源:AbstractServerInstance.java

示例14: visitArrayConstructor

import com.google.common.collect.ImmutableList; //导入方法依赖的package包/类
@Override
protected String visitArrayConstructor(ArrayConstructor node, Void context)
{
    ImmutableList.Builder<String> valueStrings = ImmutableList.builder();
    for (Expression value : node.getValues()) {
        valueStrings.add(sqlFormatter.formatSql(value));
    }
    return "ARRAY[" + Joiner.on(",").join(valueStrings.build()) + "]";
}
 
开发者ID:ajoabraham,项目名称:hue,代码行数:10,代码来源:VeroGenExpFormatter.java

示例15: getLeafKeys

import com.google.common.collect.ImmutableList; //导入方法依赖的package包/类
/**
 * Returns leaf keys issued by this chain (including lookahead zone)
 */
public List<DeterministicKey> getLeafKeys() {
    ImmutableList.Builder<DeterministicKey> keys = ImmutableList.builder();
    for (ECKey key : getKeys(true, false)) {
        DeterministicKey dKey = (DeterministicKey) key;
        if (dKey.getPath().size() == getAccountPath().size() + 2) {
            keys.add(dKey);
        }
    }
    return keys.build();
}
 
开发者ID:guodroid,项目名称:okwallet,代码行数:14,代码来源:DeterministicKeyChain.java


注:本文中的com.google.common.collect.ImmutableList.Builder方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。