简体   繁体   English

java:不兼容的类型:推理变量 T 具有不兼容的边界等式约束:下限:java.util.List<> 用于添加字段

[英]java: incompatible types: inference variable T has incompatible bounds equality constraints: lower bounds: java.util.List<> for adding field

Hello I want to add a field in HashMap but I have an error您好我想在 HashMap 中添加一个字段,但我有一个错误

"java: incompatible types: inference variable T has incompatible bounds equality constraints: java.util.Map<java.lang.String,java.lang.Object>lower bounds: java.lang.Object" and I don't see why? "java: incompatible types: inference variable T has incompatible bounds equality constraints: java.util.Map<java.lang.String,java.lang.Object>lower bounds: java.lang.Object" and I don't see why?

metadataMap.put(review.getField(), metadataMap.get(review.getField()).stream()
                            .filter(suggestion -> review.getTerm() != null && review.getTerm().equals(suggestion.get(Constants.Review.TERM)))
                            .map(termInfo -> termInfo.put(Constants.STATUS, review.getStatus()))
                            .collect(Collectors.toList()));

Here is the other intel about my code这是关于我的代码的其他信息

private void removeReviewFromSuggestionsOrDetails(ContainerModel container, ReviewModel review, String field, String instance)
        throws ApiException {
    Map<String, List<Map<String, Object>>> metadataMap = (Map<String, List<Map<String, Object>>>) container.get(field);

Should I use map there or something else?我应该在那里使用 map 还是其他什么? For add my new field Status添加我的新字段状态

Looking at such a small sample of code, I cannot reproduce the problem here and be sure of my solution.看着这么小的代码示例,我无法在这里重现问题并确定我的解决方案。

However, I would suggest you to look at your "Types".但是,我建议您查看您的“类型”。

At your "removeReviewFromSuggestionsOrDetails" function:在您的“removeReviewFromSuggestionsOrDetails”function:

Map<String, List<Map<String, Object>>> metadataMap = 

When declaring this, you are saying:声明这一点时,您是在说:

-this is a Map that receives Strings as Keys - 这是一个接收字符串作为键的 Map

-and receives a List of Maps as Values - 并接收一个映射列表作为值

Therefore, to proper use the method "put(Key, Values)" you should match the types your Map will recive with the types you use as arguments in the method.因此,要正确使用方法“put(Key, Values)”,您应该将 Map 接收的类型与您在该方法中用作 arguments 的类型相匹配。

What should be done is:应该做的是:

metadataMap.put(Keys, Values) should be metadataMap.put(String, List<Map<String, Object>>)

What you are doing is:你正在做的是:

metadataMap.put(String, Map<String, List<Map<String, Object>>>)

Do you see the problem now?你现在看到问题了吗? You are giving the put() method a String as Key and a Map as Value.你给 put() 方法一个字符串作为键和一个 Map 作为值。

However, you declared your metadataMap to receive a String as Key and a List of Maps as Value.但是,您声明了 metadataMap 以接收作为键的字符串和作为值的映射列表。

I suppose this will fix your problem.我想这会解决你的问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 java:不兼容类型:推理变量T具有不兼容的边界等式约束:下限:java.util.List &lt;&gt; - java: incompatible types: inference variable T has incompatible bounds equality constraints: lower bounds: java.util.List<> 不兼容的类型:推理变量T具有不兼容的边界等式约束:捕获#1的? 扩展java.lang.Object - incompatible types: inference variable T has incompatible bounds equality constraints: capture#1 of ? extends java.lang.Object java EnumSet,不兼容的类型:推断变量E具有不兼容的范围 - java EnumSet, incompatible types: inference variable E has incompatible bounds java:不兼容的类型:推断变量 RR 的边界不兼容 - java: incompatible types: inference variable RR has incompatible bounds Java实体组件系统-推断变量T具有不兼容的范围 - Java Entity Component System - Inference variable T has incompatible bounds 错误:不兼容的类型:推断变量R具有不兼容的界限(Lambda Java 8) - error: incompatible types: inference variable R has incompatible bounds (Lambda java 8) Java “错误:不兼容的类型:推理变量 E 的边界不兼容”错误 - Java "error: incompatible types: inference variable E has incompatible bounds" error 推断变量T具有不兼容的范围错误 - inference variable T has incompatible bounds Error 推断变量T具有不兼容的范围 - inference variable T has incompatible bounds 错误:不兼容的类型:推断变量R具有不兼容的范围 - error: incompatible types: inference variable R has incompatible bounds
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM