转换为字符串是多余的

问题描述 投票:0回答:0

为什么 IntelliJ 告诉这个从对象到字符串的转换是多余的?

public class Utils {
    
    private static Map<Class, Function<Object, ?>> functions = new HashMap<>();
    
    static {
        functions.put(String.class, v -> (String) v);
        functions.put(Foo.class, v -> {
            Foo foo = new Foo();
            foo.setA((String) ((Map<String, Object>) v).get("A"));
            foo.setB((String) ((Map<String, Object>) v).get("B"));
            return foo;
        });
    }
}

java intellij-idea casting redundancy
© www.soinside.com 2019 - 2024. All rights reserved.