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


Java Builder.put方法代码示例

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


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

示例1: serialize

import com.google.common.collect.ImmutableMap.Builder; //导入方法依赖的package包/类
@Override
Builder<String, Object> serialize(Builder<String, Object> builder) {
    super.serialize(builder);

    if (hasTitle()) {
        builder.put(BOOK_TITLE.BUKKIT, title);
    }

    if (hasAuthor()) {
        builder.put(BOOK_AUTHOR.BUKKIT, author);
    }

    if (hasPages()) {
        builder.put(BOOK_PAGES.BUKKIT, pages);
    }

    return builder;
}
 
开发者ID:alexandrage,项目名称:CauldronGit,代码行数:19,代码来源:CraftMetaBook.java

示例2: 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

示例3: 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

示例4: remove

import com.google.common.collect.ImmutableMap.Builder; //导入方法依赖的package包/类
final AbstractDOMRpcRoutingTableEntry remove(final DOMRpcImplementation implementation,
        final List<YangInstanceIdentifier> removed) {
    final Builder<YangInstanceIdentifier, List<DOMRpcImplementation>> vb = ImmutableMap.builder();
    for (final Entry<YangInstanceIdentifier, List<DOMRpcImplementation>> ve : impls.entrySet()) {
        if (removed.remove(ve.getKey())) {
            final List<DOMRpcImplementation> i = new ArrayList<>(ve.getValue());
            i.remove(implementation);
            // We could trimToSize(), but that may perform another copy just to get rid
            // of a single element. That is probably not worth the trouble.
            if (!i.isEmpty()) {
                vb.put(ve.getKey(), i);
            }
        } else {
            vb.put(ve);
        }
    }

    final Map<YangInstanceIdentifier, List<DOMRpcImplementation>> v = vb.build();
    return v.isEmpty() ? null : newInstance(v);
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:21,代码来源:AbstractDOMRpcRoutingTableEntry.java

示例5: readSandBoxFile

import com.google.common.collect.ImmutableMap.Builder; //导入方法依赖的package包/类
/**
 * Retrieve part of the contents of a file in a specific task's sandbox.
 *
 * @param taskId
 *    The task ID of the sandbox to read from
 * @param path
 *    The path to the file to be read. Relative to the sandbox root (without a leading slash)
 * @param grep
 *    Optional string to grep for
 * @param offset
 *    Byte offset to start reading from
 * @param length
 *    Maximum number of bytes to read
 * @return
 *    A {@link MesosFileChunkObject} that contains the requested partial file contents
 */
public Optional<MesosFileChunkObject> readSandBoxFile(String taskId, String path, Optional<String> grep, Optional<Long> offset, Optional<Long> length) {
  final String requestUrl = String.format(SANDBOX_READ_FILE_FORMAT, getHost(), contextPath, taskId);

  Builder<String, Object> queryParamBuider = ImmutableMap.<String, Object>builder().put("path", path);

  if (grep.isPresent()) {
    queryParamBuider.put("grep", grep.get());
  }
  if (offset.isPresent()) {
    queryParamBuider.put("offset", offset.get());
  }
  if (length.isPresent()) {
    queryParamBuider.put("length", length.get());
  }

  return getSingleWithParams(requestUrl, "Read sandbox file for task", taskId, Optional.<Map<String, Object>>of(queryParamBuider.build()), MesosFileChunkObject.class);
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:34,代码来源:SingularityClient.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: introspectWebServiceMethod

import com.google.common.collect.ImmutableMap.Builder; //导入方法依赖的package包/类
private void introspectWebServiceMethod(Builder<WebPath, Handler> builder, String httpMethod, String basePath,
		Object webService, Method method) {
	String path = basePath;
	Path methodPath = method.getAnnotation(Path.class);
	if (methodPath != null) {
		path = Joiner.on("/").join(Arrays.asList(basePath, methodPath.value()));
	}
	path = CharMatcher.is('/').collapseFrom(path, '/');

	WebPath webPath = new WebPath(httpMethod, path);

	logger.log(Level.FINEST, format("HTTP {0} {1} -> {2}.{3}", httpMethod, path,
			webService.getClass().getSimpleName(), method.getName()));

	builder.put(webPath, new Handler(webService, method));

}
 
开发者ID:greensopinion,项目名称:greenbeans,代码行数:18,代码来源:WebDispatch.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: serialize

import com.google.common.collect.ImmutableMap.Builder; //导入方法依赖的package包/类
@Override
Builder<String, Object> serialize(Builder<String, Object> builder) {
    super.serialize(builder);

    if (hasColor()) {
        builder.put(COLOR.BUKKIT, color);
    }

    return builder;
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:11,代码来源:CraftMetaLeatherArmor.java

示例10: serialize

import com.google.common.collect.ImmutableMap.Builder; //导入方法依赖的package包/类
@Override
Builder<String, Object> serialize(Builder<String, Object> builder) {
    super.serialize(builder);

    if (hasEffect()) {
        builder.put(EXPLOSION.BUKKIT, effect);
    }

    return builder;
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:11,代码来源:CraftMetaCharge.java

示例11: serialize

import com.google.common.collect.ImmutableMap.Builder; //导入方法依赖的package包/类
@Override
Builder<String, Object> serialize(Builder<String, Object> builder) {
    super.serialize(builder);
    if (hasOwner()) {
        return builder.put(SKULL_OWNER.BUKKIT, this.profile.getName());
    }
    return builder;
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:9,代码来源:CraftMetaSkull.java

示例12: 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("youtube", YoutubeAttachmentBean.class);
	return builder.build();
}
 
开发者ID:equella,项目名称:Equella,代码行数:9,代码来源:YoutubeAttachmentSerializer.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
public Map<String, Class<? extends EquellaAttachmentBean>> getAttachmentBeanTypes()
{
	Builder<String, Class<? extends EquellaAttachmentBean>> builder = ImmutableMap.builder();
	builder.put("file", FileAttachmentBean.class);
	builder.put("url", UrlAttachmentBean.class);
	builder.put("zip", ZipAttachmentBean.class);
	builder.put("package", PackageAttachmentBean.class);
	builder.put("package-res", PackageResourceAttachmentBean.class);
	builder.put("scorm", ScormAttachmentBean.class);
	builder.put("scorm-res", ScormResourceAttachmentBean.class);
	return builder.build();
}
 
开发者ID:equella,项目名称:Equella,代码行数:14,代码来源:StandardAttachmentSerializer.java

示例15: tags

import com.google.common.collect.ImmutableMap.Builder; //导入方法依赖的package包/类
private ImmutableMap<String, String> tags(Feature feature) {
    Builder<String, String> capital = capital(feature);
    Double geonameid = feature.getDouble("GEONAMEID");
    if (geonameid != null) {
        List<AlternateName> frenchNames = geonames.frenchNames(geonameid.intValue());
        if (!frenchNames.isEmpty()) {
            capital = capital.put("name:fr", frenchNames.get(0).getValue());
        }
    }
    return capital
            .put("name", feature.getString("NAME"))
            .put("population", feature.getInteger("POP_MAX").toString())
            .put("place", feature.getInteger("POP_MAX") > 100000 ? "city" : feature.getInteger("POP_MAX") > 10000 ? "town" : "village")
            .build();
}
 
开发者ID:Mappy,项目名称:fpm,代码行数:16,代码来源:PopulatedPlacesShapefile.java


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