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


Java Builder.build方法代码示例

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


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

示例1: viewUserOpenSteps

import com.google.common.collect.ImmutableMap.Builder; //导入方法依赖的package包/类
/**
 * 获取未完成的steps
 * 
 * @param companyId
 * @param userId
 * @return
 */
@RequestMapping(value = "/{companyId}/user/{userId}/uncompletedSteps", method = RequestMethod.GET)
@Interceptors({ CompanyMemberRequired.class, UserChecking.class })
@ResponseBody
public Map<String, Object> viewUserOpenSteps(@PathVariable int companyId, @PathVariable int userId) {
    Builder<String, Object> builder = ImmutableMap.builder();
    Map<Integer, String> projectIdToName = getProjectIdAndNameByCompanyId(companyId);
    builder.put("projectsName", projectIdToName);
    List<Integer> projectList = getProjectListOfCurrentUser(companyId);
    Map<Integer, List<Step>> steps = stepService.getOpenStepsByUser(userId, projectList);
    Map<Integer, List<StepDTO>> stepsDto = makeUserUncompletedStepsMapSerilizable(steps);
    builder.put("uncompletedSteps", stepsDto);

    Map<Integer, List<User>> users = userService.getAllProjectUsersInCompany(companyId);
    Map<Integer, List<UserDTO>> userDtos = makeUserUncompletedTodosMapSerilizable(users);
    builder.put("userDtos", userDtos);
    UserDTO userDto = UserTransform.userToUserDTO(userService.getById(userId));
    builder.put("user", userDto);

    return builder.build();
}
 
开发者ID:sercxtyf,项目名称:onboard,代码行数:28,代码来源:UserAPIController.java

示例2: readExternal

import com.google.common.collect.ImmutableMap.Builder; //导入方法依赖的package包/类
@Override
public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
    final int metaSize = in.readInt();
    Preconditions.checkArgument(metaSize >= 0, "Invalid negative metadata map length %s", metaSize);

    // Default pre-allocate is 4, which should be fine
    final Builder<Class<? extends ShardDataTreeSnapshotMetadata<?>>, ShardDataTreeSnapshotMetadata<?>>
            metaBuilder = ImmutableMap.builder();
    for (int i = 0; i < metaSize; ++i) {
        final ShardDataTreeSnapshotMetadata<?> m = (ShardDataTreeSnapshotMetadata<?>) in.readObject();
        if (m != null) {
            metaBuilder.put(m.getType(), m);
        } else {
            LOG.warn("Skipping null metadata");
        }
    }

    metadata = metaBuilder.build();
    rootNode = Verify.verifyNotNull(SerializationUtils.deserializeNormalizedNode(in));
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:21,代码来源:MetadataShardDataTreeSnapshot.java

示例3: JobMetrics

import com.google.common.collect.ImmutableMap.Builder; //导入方法依赖的package包/类
public JobMetrics(Job job, String bytesReplicatedKey) {
  Builder<String, Long> builder = ImmutableMap.builder();
  if (job != null) {
    Counters counters;
    try {
      counters = job.getCounters();
    } catch (IOException e) {
      throw new CircusTrainException("Unable to get counters from job.", e);
    }
    if (counters != null) {
      for (CounterGroup group : counters) {
        for (Counter counter : group) {
          builder.put(DotJoiner.join(group.getName(), counter.getName()), counter.getValue());
        }
      }
    }
  }
  metrics = builder.build();
  Long bytesReplicatedValue = metrics.get(bytesReplicatedKey);
  if (bytesReplicatedValue != null) {
    bytesReplicated = bytesReplicatedValue;
  } else {
    bytesReplicated = 0L;
  }
}
 
开发者ID:HotelsDotCom,项目名称:circus-train,代码行数:26,代码来源:JobMetrics.java

示例4: mapGraphValue

import com.google.common.collect.ImmutableMap.Builder; //导入方法依赖的package包/类
@Override
public Object mapGraphValue(@NonNull RefProperty schema,
    @NonNull GraphEntityContext graphEntityContext,
    @NonNull ValueContext valueContext,
    @NonNull SchemaMapperAdapter schemaMapperAdapter) {

  Model refModel = graphEntityContext.getSwaggerDefinitions().get(schema.getSimpleRef());

  if (refModel == null) {
    throw new SchemaMapperRuntimeException(String.format(
        "Unable to resolve reference to swagger model: '%s'.", schema.getSimpleRef()));
  }

  Builder<String, Object> builder = ImmutableMap.builder();
  refModel.getProperties().forEach((propKey, propValue) -> builder.put(propKey,
      Optional.fromNullable(schemaMapperAdapter.mapGraphValue(propValue, graphEntityContext,
          valueContext, schemaMapperAdapter))));

  return builder.build();
}
 
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:21,代码来源:RefSchemaMapper.java

示例5: getPrivilegesForObjects

import com.google.common.collect.ImmutableMap.Builder; //导入方法依赖的package包/类
@Override
@Transactional
public <T> Map<T, Map<String, Boolean>> getPrivilegesForObjects(Collection<String> privileges,
	Collection<T> domainObjs)
{
	if( CurrentUser.getUserState().isSystem() )
	{
		Builder<String, Boolean> builder = ImmutableMap.builder();
		for( String priv : privileges )
		{
			builder.put(priv, true);
		}
		ImmutableMap<String, Boolean> allPrivs = builder.build();
		Builder<T, Map<String, Boolean>> domainBuilder = ImmutableMap.builder();
		for( T t : domainObjs )
		{
			domainBuilder.put(t, allPrivs);
		}
		return domainBuilder.build();
	}
	return getObjectToPrivileges(privileges, domainObjs);
}
 
开发者ID:equella,项目名称:Equella,代码行数:23,代码来源:TLEAclManagerImpl.java

示例6: assignConstructionDef

import com.google.common.collect.ImmutableMap.Builder; //导入方法依赖的package包/类
/**
 * Define what each character represents within the block map
 * @param representation char to unlocal.getZ()ed block name map
 * @exception NullPointerException thrown if block doesn't exist.
 */
public void assignConstructionDef(ImmutableMap<Character, String> representation)
{
    Builder<Character, IBlockState> builder = ImmutableMap.builder();

    for (final Character c: representation.keySet())
    {
        final String blockName = representation.get(c);
        final Block block = Block.getBlockFromName(blockName);

        checkNotNull(block, "assignConstructionDef.Block does not exist " + blockName);

        builder.put(c, block.getDefaultState());
    }

    //default
    builder.put(' ', Blocks.AIR.getDefaultState());

    conDef = builder.build();
}
 
开发者ID:FoudroyantFactotum,项目名称:Structure,代码行数:25,代码来源:StructureDefinitionBuilder.java

示例7: DtoTest

import com.google.common.collect.ImmutableMap.Builder; //导入方法依赖的package包/类
/**
 * Creates an instance of {@link DtoTest} with ignore fields and additional custom mappers.
 *
 * @param customMappers Any custom mappers for a given class type.
 * @param ignoreFields The getters which should be ignored (e.g., "getId" or "isActive").
 */
protected DtoTest(Map<Class<?>, Supplier<?>> customMappers, Set<String> ignoreFields) {
    this.ignoredGetFields = new HashSet<>();
    if (ignoreFields != null) {
        this.ignoredGetFields.addAll(ignoreFields);
    }
    this.ignoredGetFields.add("getClass");

    if (customMappers == null) {
        this.mappers = DEFAULT_MAPPERS;
    } else {
        final Builder<Class<?>, Supplier<?>> builder = ImmutableMap.builder();
        builder.putAll(customMappers);
        builder.putAll(DEFAULT_MAPPERS);
        this.mappers = builder.build();
    }
}
 
开发者ID:Blastman,项目名称:DtoTester,代码行数:23,代码来源:DtoTest.java

示例8: CommonFormatter

import com.google.common.collect.ImmutableMap.Builder; //导入方法依赖的package包/类
public CommonFormatter(Collection<String> ignoreMessages, boolean colorizeTag, boolean truncateColor
        , Map<String, String> levelColors) {
    this.ignoreMessages = ImmutableSet.copyOf(ignoreMessages);

    this.colorizeTag = colorizeTag;
    this.truncateColor = truncateColor;

    Builder<String, String> builder = ImmutableMap.builder();
    for (Map.Entry<String, String> entry : levelColors.entrySet()) {
        if ("INFO".equals(entry.getKey())) {
            continue;
        }

        builder.put(entry.getKey(), format(entry.getValue()));
    }

    this.levelColors = builder.build();
}
 
开发者ID:games647,项目名称:ColorConsole,代码行数:19,代码来源:CommonFormatter.java

示例9: testBuilder_orderEntriesByValueAfterExactSizeBuild

import com.google.common.collect.ImmutableMap.Builder; //导入方法依赖的package包/类
public void testBuilder_orderEntriesByValueAfterExactSizeBuild() {
  Builder<String, Integer> builder = new Builder<String, Integer>(2)
      .put("four", 4)
      .put("one", 1);
  ImmutableMap<String, Integer> keyOrdered = builder.build();
  ImmutableMap<String, Integer> valueOrdered =
      builder.orderEntriesByValue(Ordering.natural()).build();
  assertMapEquals(keyOrdered, "four", 4, "one", 1);
  assertMapEquals(valueOrdered, "one", 1, "four", 4);
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:11,代码来源:ImmutableMapTest.java

示例10: testPuttingTheSameKeyTwiceThrowsOnBuild

import com.google.common.collect.ImmutableMap.Builder; //导入方法依赖的package包/类
public void testPuttingTheSameKeyTwiceThrowsOnBuild() {
  Builder<String, Integer> builder = new Builder<String, Integer>()
      .put("one", 1)
      .put("one", 1); // throwing on this line would be even better

  try {
    builder.build();
    fail();
  } catch (IllegalArgumentException expected) {
  }
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:12,代码来源:ImmutableMapTest.java

示例11: takeStateSnapshot

import com.google.common.collect.ImmutableMap.Builder; //导入方法依赖的package包/类
/**
 * Take a snapshot of current state for later recovery.
 *
 * @return A state snapshot
 */
@Nonnull ShardDataTreeSnapshot takeStateSnapshot() {
    final NormalizedNode<?, ?> rootNode = dataTree.takeSnapshot().readNode(YangInstanceIdentifier.EMPTY).get();
    final Builder<Class<? extends ShardDataTreeSnapshotMetadata<?>>, ShardDataTreeSnapshotMetadata<?>> metaBuilder =
            ImmutableMap.builder();

    for (ShardDataTreeMetadata<?> m : metadata) {
        final ShardDataTreeSnapshotMetadata<?> meta = m.toSnapshot();
        if (meta != null) {
            metaBuilder.put(meta.getType(), meta);
        }
    }

    return new MetadataShardDataTreeSnapshot(rootNode, metaBuilder.build());
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:20,代码来源:ShardDataTree.java

示例12: run

import com.google.common.collect.ImmutableMap.Builder; //导入方法依赖的package包/类
@Override
public void run(ApplicationArguments args) {
  locomotiveListener.circusTrainStartUp(args.getSourceArgs(), EventUtils.toEventSourceCatalog(sourceCatalog),
      EventUtils.toEventReplicaCatalog(replicaCatalog, security));
  CompletionCode completionCode = CompletionCode.SUCCESS;
  Builder<String, Long> metrics = ImmutableMap.builder();
  replicationFailures = 0;
  long replicated = 0;

  LOG.info("{} tables to replicate.", tableReplications.size());
  for (TableReplication tableReplication : tableReplications) {
    String summary = getReplicationSummary(tableReplication);
    LOG.info("Replicating {} replication mode '{}'.", summary, tableReplication.getReplicationMode());
    try {
      Replication replication = replicationFactory.newInstance(tableReplication);
      tableReplicationListener.tableReplicationStart(EventUtils.toEventTableReplication(tableReplication),
          replication.getEventId());
      replication.replicate();
      LOG.info("Completed replicating: {}.", summary);
      tableReplicationListener.tableReplicationSuccess(EventUtils.toEventTableReplication(tableReplication),
          replication.getEventId());
    } catch (Throwable t) {
      replicationFailures++;
      completionCode = CompletionCode.FAILURE;
      LOG.error("Failed to replicate: {}.", summary, t);
      tableReplicationListener.tableReplicationFailure(EventUtils.toEventTableReplication(tableReplication),
          EventUtils.EVENT_ID_UNAVAILABLE, t);
    }
    replicated++;
  }

  metrics.put("tables_replicated", replicated);
  metrics.put(completionCode.getMetricName(), completionCode.getCode());
  Map<String, Long> metricsMap = metrics.build();
  metricSender.send(metricsMap);
  locomotiveListener.circusTrainShutDown(completionCode, metricsMap);
}
 
开发者ID:HotelsDotCom,项目名称:circus-train,代码行数:38,代码来源:Locomotive.java

示例13: setSchemaContext

import com.google.common.collect.ImmutableMap.Builder; //导入方法依赖的package包/类
DOMRpcRoutingTable setSchemaContext(final SchemaContext context) {
    final Builder<SchemaPath, AbstractDOMRpcRoutingTableEntry> b = ImmutableMap.builder();

    for (Entry<SchemaPath, AbstractDOMRpcRoutingTableEntry> e : rpcs.entrySet()) {
        b.put(e.getKey(), createRpcEntry(context, e.getKey(), e.getValue().getImplementations()));
    }

    return new DOMRpcRoutingTable(b.build(), context);
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:10,代码来源:DOMRpcRoutingTable.java

示例14: getAttachmentBeanTypes

import com.google.common.collect.ImmutableMap.Builder; //导入方法依赖的package包/类
@Override
@SuppressWarnings("nls")
public Map<String, Class<? extends EquellaAttachmentBean>> getAttachmentBeanTypes()
{
	Builder<String, Class<? extends EquellaAttachmentBean>> builder = ImmutableMap.builder();
	builder.put("echo", EchoAttachmentBean.class);
	return builder.build();
}
 
开发者ID:equella,项目名称:Equella,代码行数:9,代码来源:EchoAttachmentSerializer.java

示例15: getAttachmentBeanTypes

import com.google.common.collect.ImmutableMap.Builder; //导入方法依赖的package包/类
@SuppressWarnings({"nls"})
@Override
public Map<String, Class<? extends EquellaAttachmentBean>> getAttachmentBeanTypes()
{
	Builder<String, Class<? extends EquellaAttachmentBean>> builder = ImmutableMap.builder();
	builder.put("googlebook", GoogleBookAttachmentBean.class);
	return builder.build();
}
 
开发者ID:equella,项目名称:Equella,代码行数:9,代码来源:GoogleBookAttachmentSerializer.java


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