本文整理汇总了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();
}
示例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));
}
示例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;
}
}
示例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();
}
示例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);
}
示例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();
}
示例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();
}
}
示例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();
}
示例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);
}
示例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) {
}
}
示例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());
}
示例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);
}
示例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);
}
示例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();
}
示例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();
}