简体   繁体   English

方法映射((<no type> cfg) -&gt; {}) 对于 List 类型是未定义的<capture#1-of ? extends Config>

[英]The method map((<no type> cfg) -> {}) is undefined for the type List<capture#1-of ? extends Config>

I am afraid this is the matter of simple lambda map function.恐怕这是简单的 lambda 映射函数的问题。 But I have no idea how.但我不知道如何。 Below is my java codes,下面是我的java代码,

public SparkConf createSparkConf(String appName, Config config) {
    SparkConf sparkConf = new SparkConf().setMaster(config.getString("system.master")).setAppName(appName);

    config.getConfigList("spark").map(cfg -> {
        String name = "spark." + cfg.getString("name");
        String value = cfg.getString("value");
        sparkConf.set(name, value);
    });

    if(config.hasPath("app")) {
        config.getConfigList("app").map(cfg -> {
            String name = "spark." + cfg.getString("name");
            String value = cfg.getString("value");
            sparkConf.set(name, value);
        });
    }

    return sparkConf;
}

But the map function throws the following exception.但是 map 函数抛出以下异常。

The method map((<no type> cfg) -> {}) is undefined for the type List<capture#1-of ? extends Config>

config.getConfigList("app") line returns List<Config> , but I have no idea why map function throws such errors. config.getConfigList("app")行返回List<Config> ,但我不知道为什么 map 函数会抛出这样的错误。 Any idea?任何的想法?

You're looking for the forEach method, since you're not collecting the results of the map operation.您正在寻找forEach方法,因为您没有收集map操作的结果。 Also you can call list.stream().map(...) to reach it.您也可以调用list.stream().map(...)来访问它。

暂无
暂无

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

相关问题 类型Map <String中的方法,捕获#1-of? extends Object>不适用 - Method in the type Map<String,capture#1-of ? extends Object> is not applicable Java泛型编译错误-方法method(Class <capture#1-of ? extends Interface> ) <type> 不适用于参数 - Java generics compilation error - The method method(Class<capture#1-of ? extends Interface>) in the type <type> is not applicable for the arguments java generics - Comparable 类型中的方法 compareTo(capture#1-of?)<capture#1-of ?> 不适用于 arguments</capture#1-of> - java generics - The method compareTo(capture#1-of ?) in the type Comparable<capture#1-of ?> is not applicable for the arguments 未定义类型为Class的方法<capture#3-of ? extends Command> - The method is undefined for the type Class<capture#3-of ? extends Command> 类型不匹配:无法从Class转换 <capture#1-of ?> 上课 <?> [] - Type mismatch: cannot convert from Class<capture#1-of ?> to Class<?>[] 验证器类型中的方法validate(capture#2-of?extended Object) <capture#2-of ? extends Object> 不适用于参数(字符串) - The method validate(capture#2-of ? extends Object) in the type Validator<capture#2-of ? extends Object> is not applicable for the arguments (String) 类型不匹配:无法从 List 转换<capture#2-of ? extends idto>列出<followingresponsedto></followingresponsedto></capture#2-of> - Type mismatch: cannot convert from List<capture#2-of ? extends IDto> to List<FollowingResponseDto> 泛型:无法从 <capture#1-of ? extends Object,D> 至 <S,D> - Generics: cannot convert from <capture#1-of ? extends Object,D> to <S,D> Java泛型:Comparable类型的compareTo(capture#2-of?扩展E)方法不适用于自变量(Comparable) - Java Generics :The method compareTo(capture#2-of ? extends E) in the type Comparable is not applicable for the arguments (Comparable) 类型列表的get(int)方法未定义 - get (int) method undefined for the type list
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM