本文整理汇总了Java中com.google.common.collect.ImmutableMap.get方法的典型用法代码示例。如果您正苦于以下问题:Java ImmutableMap.get方法的具体用法?Java ImmutableMap.get怎么用?Java ImmutableMap.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.common.collect.ImmutableMap
的用法示例。
在下文中一共展示了ImmutableMap.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: extractLdpathNamespaces
import com.google.common.collect.ImmutableMap; //导入方法依赖的package包/类
private ImmutableMap<String, String> extractLdpathNamespaces(Swagger swagger) {
Map<String, Object> extensions = swagger.getVendorExtensions();
ImmutableMap<String, Object> vendorExtensions =
extensions == null ? ImmutableMap.of() : ImmutableMap.copyOf(extensions);
if (vendorExtensions.containsKey(OpenApiSpecificationExtensions.LDPATH_NAMESPACES)) {
Object ldPathNamespaces =
vendorExtensions.get(OpenApiSpecificationExtensions.LDPATH_NAMESPACES);
try {
return ImmutableMap.copyOf((Map<String, String>) ldPathNamespaces);
} catch (ClassCastException cce) {
throw new LdPathExecutorRuntimeException(String.format(
"Vendor extension '%s' should contain a map of namespaces (eg. "
+ "{ \"rdfs\": \"http://www.w3.org/2000/01/rdf-schema#\", "
+ "\"rdf\": \"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"})",
OpenApiSpecificationExtensions.LDPATH_NAMESPACES), cce);
}
}
return ImmutableMap.of();
}
示例2: mapClassToBuildRule
import com.google.common.collect.ImmutableMap; //导入方法依赖的package包/类
/** Maps each top level class name to a build rule. */
private Map<String, BuildRule> mapClassToBuildRule(
ImmutableGraph<ImmutableSet<Path>> componentDAG,
Map<String, Path> classToSrcFileMap,
Graph<String> classGraph) {
ImmutableMap<Path, Path> dirToBuildFileMap = mapDirectoriesToPackages(componentDAG.nodes());
Map<Path, BuildRule> srcToTargetMap = new HashMap<>();
for (ImmutableSet<Path> component : componentDAG.nodes()) {
Path buildFilePath = dirToBuildFileMap.get(component.iterator().next().getParent());
BuildRule rule = new ProjectBuildRule(component, buildFilePath, workspace);
component.stream().forEach(src -> srcToTargetMap.put(src, rule));
}
ImmutableMap.Builder<String, BuildRule> classToBuildRuleMap = ImmutableMap.builder();
for (String className : classGraph.nodes()) {
Path srcFile = classToSrcFileMap.get(className);
classToBuildRuleMap.put(className, srcToTargetMap.get(srcFile));
}
return classToBuildRuleMap.build();
}
示例3: MultiLayerBakedModel
import com.google.common.collect.ImmutableMap; //导入方法依赖的package包/类
public MultiLayerBakedModel(ImmutableMap<Optional<BlockRenderLayer>, IBakedModel> models, IBakedModel missing, ImmutableMap<TransformType, TRSRTransformation> cameraTransforms)
{
this.models = models;
this.cameraTransforms = cameraTransforms;
this.missing = missing;
if(models.containsKey(Optional.absent()))
{
base = models.get(Optional.absent());
}
else
{
base = missing;
}
ImmutableMap.Builder<Optional<EnumFacing>, ImmutableList<BakedQuad>> quadBuilder = ImmutableMap.builder();
quadBuilder.put(Optional.<EnumFacing>absent(), buildQuads(models, Optional.<EnumFacing>absent()));
for(EnumFacing side: EnumFacing.values())
{
quadBuilder.put(Optional.of(side), buildQuads(models, Optional.of(side)));
}
quads = quadBuilder.build();
}
示例4: retexture
import com.google.common.collect.ImmutableMap; //导入方法依赖的package包/类
@Override
public ModelWrapper retexture(ImmutableMap<String, String> textures)
{
ImmutableMap.Builder<String, ResourceLocation> builder = ImmutableMap.builder();
for(Map.Entry<String, ResourceLocation> e : this.textures.entrySet())
{
String path = e.getKey();
String loc = getLocation(path);
if(textures.containsKey(loc))
{
String newLoc = textures.get(loc);
if(newLoc == null) newLoc = getLocation(path);
builder.put(e.getKey(), new ResourceLocation(newLoc));
}
else
{
builder.put(e);
}
}
return new ModelWrapper(modelLocation, model, meshes, smooth, gui3d, defaultKey, builder.build());
}
示例5: sortMemgraphObjectsByResultOrder
import com.google.common.collect.ImmutableMap; //导入方法依赖的package包/类
private <T extends MemgraphObject> Iterable<T> sortMemgraphObjectsByResultOrder(Iterable<T> MemgraphObjects, List<String> ids) {
ImmutableMap<String, T> itemMap = Maps.uniqueIndex(MemgraphObjects, MemgraphObject -> {
if (MemgraphObject instanceof Element) {
return ((Element) MemgraphObject).getId();
} else if (MemgraphObject instanceof ExtendedDataRow) {
return ElasticsearchExtendedDataIdUtils.toDocId(((ExtendedDataRow) MemgraphObject).getId());
} else {
throw new MemgraphException("Unhandled searchable item type: " + MemgraphObject.getClass().getName());
}
});
List<T> results = new ArrayList<>();
for (String id : ids) {
T item = itemMap.get(id);
if (item != null) {
results.add(item);
}
}
return results;
}
示例6: selectClosestTo
import com.google.common.collect.ImmutableMap; //导入方法依赖的package包/类
private static Symbol selectClosestTo(Collection<Symbol> docIDs,
ImmutableMap<Symbol, Integer> docIDsToNumResponses, double targetSize) {
checkArgument(!docIDs.isEmpty());
double smalletDivergence = Integer.MAX_VALUE;
Symbol closestDocID = null;
for (final Symbol docID : docIDs) {
final int size = docIDsToNumResponses.get(docID);
final double divergence = Math.abs(targetSize - size);
if (divergence < smalletDivergence) {
smalletDivergence = divergence;
closestDocID = docID;
}
}
return closestDocID;
}
示例7: isHostNet
import com.google.common.collect.ImmutableMap; //导入方法依赖的package包/类
/**
* 容器网络模式是否为host模式
* @param containerId
* @return
*/
public static boolean isHostNet(String containerId){
String cacheKey = "isHostNet" + containerId;
Boolean v = (Boolean) getCache(cacheKey);
if (v != null){
return v;
}
Boolean value = false;
try {
ContainerInfo containerInfo = getContainerInfo(containerId);
if (containerInfo != null) {
ImmutableMap<String, AttachedNetwork> networks = containerInfo.networkSettings().networks();
if (networks != null && !networks.isEmpty()){
value = networks.get("host") != null && StringUtils.isNotEmpty(networks.get("host").ipAddress());
setCache(cacheKey,value);
}else {
log.warn("容器{}无Networks配置",containerInfo.name());
}
}
} catch (Exception e) {
log.error("",e);
}
return value;
}
示例8: postTopicData
import com.google.common.collect.ImmutableMap; //导入方法依赖的package包/类
@POST
@Path("/topics/{topicName}")
public Response postTopicData(@PathParam("topicName") String topicName,
String data) {
try {
ImmutableMap<String, String> params = parseUrlEncodedParams(data);
String key = params.get("key");
String value = params.get("value");
if (key == null || value == null) {
return responseFactory.createBadRequestResponse("One of the required post params 'key' " +
"or 'value' are missing");
}
if (!doesTopicExist(topicName)) {
return responseFactory.createNotFoundResponse(String.format("No topic exists with the name [%s]", topicName));
}
RecordMetadata metadata = kafkaProducerWrapper.publish(key, value, topicName);
return responseFactory.createOkResponse(metadata);
} catch (Exception e) {
return responseFactory.createServerErrorResponse(e);
}
}
示例9: unmappedFieldType
import com.google.common.collect.ImmutableMap; //导入方法依赖的package包/类
/**
* Given a type (eg. long, string, ...), return an anonymous field mapper that can be used for search operations.
*/
public MappedFieldType unmappedFieldType(String type) {
final ImmutableMap<String, MappedFieldType> unmappedFieldMappers = this.unmappedFieldTypes;
MappedFieldType fieldType = unmappedFieldMappers.get(type);
if (fieldType == null) {
final Mapper.TypeParser.ParserContext parserContext = documentMapperParser().parserContext(type);
Mapper.TypeParser typeParser = parserContext.typeParser(type);
if (typeParser == null) {
throw new IllegalArgumentException("No mapper found for type [" + type + "]");
}
final Mapper.Builder<?, ?> builder = typeParser.parse("__anonymous_" + type, ImmutableMap.<String, Object>of(), parserContext);
final BuilderContext builderContext = new BuilderContext(indexSettings, new ContentPath(1));
fieldType = ((FieldMapper)builder.build(builderContext)).fieldType();
// There is no need to synchronize writes here. In the case of concurrent access, we could just
// compute some mappers several times, which is not a big deal
this.unmappedFieldTypes = ImmutableMap.<String, MappedFieldType>builder()
.putAll(unmappedFieldMappers)
.put(type, fieldType)
.build();
}
return fieldType;
}
示例10: copyFallingBackTo
import com.google.common.collect.ImmutableMap; //导入方法依赖的package包/类
/**
* Takes this AnswerKey as ground truth, and takes unannotated or assessed Responses in fallback
* and adds them to the AnswerKey.
*
* If the CAS for an AssessedResponse is known, prefer that CAS to the CAS in fallback.
*
* Does not handle the case where the fallback AnswerKey has an Assessment that this AnswerKey
* does not.
*/
public AnswerKey copyFallingBackTo(AnswerKey fallback) {
final Builder ret = modifiedCopyBuilder();
final ImmutableMap<String, Response> unannotatedHere = Maps.uniqueIndex(unannotatedResponses(),
ResponseFunctions.uniqueIdentifier());
final ImmutableMap<String, AssessedResponse> idToAssessedHere =
Maps.uniqueIndex(annotatedResponses(),
Functions.compose(ResponseFunctions.uniqueIdentifier(),
AssessedResponseFunctions.response()));
final Set<String> idsHere = Sets.union(unannotatedHere.keySet(), idToAssessedHere.keySet());
final ImmutableMap<String, Response> unannotatedThere = Maps.uniqueIndex(
fallback.unannotatedResponses(), ResponseFunctions.uniqueIdentifier());
final ImmutableMap<String, AssessedResponse> idToAssessedThere =
Maps.uniqueIndex(fallback.annotatedResponses(),
Functions.compose(ResponseFunctions.uniqueIdentifier(),
AssessedResponseFunctions.response()));
final Set<String> idsThere = Sets.union(unannotatedThere.keySet(), idToAssessedThere.keySet());
final Set<String> idsOnlyInFallback = Sets.difference(idsThere, idsHere);
for (final String id : idsOnlyInFallback) {
if (unannotatedThere.containsKey(id)) {
ret.addUnannotated(unannotatedThere.get(id));
}
if (idToAssessedThere.containsKey(id)) {
final AssessedResponse r = idToAssessedThere.get(id);
final int CASGroup;
if (corefAnnotation().CASesToIDs().containsKey(r.response().canonicalArgument())) {
CASGroup = corefAnnotation().CASesToIDs().get(r.response().canonicalArgument());
} else {
CASGroup = fallback.corefAnnotation().CASesToIDs().get(r.response().canonicalArgument());
}
ret.addAnnotated(r, CASGroup);
}
}
return ret.build();
}
示例11: getEREDocument
import com.google.common.collect.ImmutableMap; //导入方法依赖的package包/类
private EREDocument getEREDocument(final Symbol docID,
final ImmutableMap<Symbol, File> goldDocIDToFileMap) throws IOException {
final File ereFileName = goldDocIDToFileMap.get(docID);
if (ereFileName == null) {
throw new RuntimeException("Missing key file for " + docID);
}
final EREDocument ereDoc = ereLoader.loadFrom(ereFileName);
// the LDC provides certain ERE documents with "-kbp" in the name. The -kbp is used by them
// internally for some form of tracking but doesn't appear to the world, so we remove it.
if (!ereDoc.getDocId().replace("-kbp", "").equals(docID.asString().replace(".kbp", ""))) {
log.warn("Fetched document ID {} does not equal stored {}", ereDoc.getDocId(), docID);
}
return ereDoc;
}
示例12: finish
import com.google.common.collect.ImmutableMap; //导入方法依赖的package包/类
@Override
public void finish() throws IOException {
final String scorePattern = "TP: %d, FP: %d, FN: %d, Score: %f\n";
// see guidelines section 7.3.1.1.4 for aggregating rules:
// sum over per document contributions, divide by total number of TRFRs in the answer key
// Math.max is to skip division by zero errors.
final double overAllArgScore =
100 * scoreAggregator / Math.max(0.0 + aggregateFNs + aggregateTPs, 1.0);
final String scoreString =
String.format(scorePattern, aggregateTPs, aggregateFPs, aggregateFNs, overAllArgScore);
Files.asCharSink(new File(outputDir, "argScores.txt"), Charsets.UTF_8).write(scoreString);
final File jsonArgScores = new File(outputDir, "argScore.json");
serializer.serializeTo(ArgScoreSummary.of(overAllArgScore,
FMeasureCounts.fromTPFPFN(aggregateTPs, aggregateFPs, aggregateFNs)),
Files.asByteSink(jsonArgScores));
final ImmutableMap<Symbol, Double> scores = this.scores.build();
final ImmutableMap<Symbol, Integer> falsePositives = this.falsePositives.build();
final ImmutableMap<Symbol, Integer> truePositives = this.truePositives.build();
final ImmutableMap<Symbol, Integer> falseNegatives = this.falseNegatives.build();
final File perDocDir = new File(outputDir, "perDocument");
for (final Symbol docid : scores.keySet()) {
final File docDir = new File(perDocDir, docid.asString());
docDir.mkdirs();
final File docScore = new File(docDir, "argScores.txt");
// avoid dividing by zero
final double normalizer = Math.max(truePositives.get(docid) + falseNegatives.get(docid), 1);
// see guidelines referenced above
// pretends that the corpus is a single document
final double normalizedAndScaledArgScore = 100 * scores.get(docid) / normalizer;
Files.asCharSink(docScore, Charsets.UTF_8).write(String
.format(scorePattern, truePositives.get(docid), falsePositives.get(docid),
falseNegatives.get(docid), normalizedAndScaledArgScore));
final File docJsonArgScores = new File(docDir, "argScores.json");
serializer.serializeTo(normalizedAndScaledArgScore, Files.asByteSink(docJsonArgScores));
}
}
示例13: createSimpleCharEscaper
import com.google.common.collect.ImmutableMap; //导入方法依赖的package包/类
static CharEscaper createSimpleCharEscaper(
final ImmutableMap<Character, char[]> replacementMap) {
return new CharEscaper() {
@Override protected char[] escape(char c) {
return replacementMap.get(c);
}
};
}
示例14: fieldMappings
import com.google.common.collect.ImmutableMap; //导入方法依赖的package包/类
/**
* Returns the mappings of a specific field.
*
* @param field field name as specified in the {@link GetFieldMappingsRequest}
* @return FieldMappingMetaData for the requested field or null if not found.
*/
public FieldMappingMetaData fieldMappings(String index, String type, String field) {
ImmutableMap<String, ImmutableMap<String, FieldMappingMetaData>> indexMapping = mappings.get(index);
if (indexMapping == null) {
return null;
}
ImmutableMap<String, FieldMappingMetaData> typeMapping = indexMapping.get(type);
if (typeMapping == null) {
return null;
}
return typeMapping.get(field);
}
示例15: createSimpleUnicodeEscaper
import com.google.common.collect.ImmutableMap; //导入方法依赖的package包/类
static UnicodeEscaper createSimpleUnicodeEscaper(
final ImmutableMap<Integer, char[]> replacementMap) {
return new UnicodeEscaper() {
@Override protected char[] escape(int cp) {
return replacementMap.get(cp);
}
};
}