有没有办法检查Lambda变量的显式类型?

以这个 Lambda 为例:

final List<String> badKeys = pivMap.entrySet().stream()
 .filter(entry -> StringUtils.trimToNull(entry.getValue()) == null || entry.getValue().equals("{}") || entry.getValue().equals("{ }"))
 .map(Map.Entry::getKey)
 .collect(Collectors.toList());

我们要确保 Lambda 变量上有一个显式类型:

final List<String> badKeys = pivMap.entrySet().stream()
 .filter((final Map.Entry<String, String> entry) -> StringUtils.trimToNull(entry.getValue()) == null || entry.getValue().equals("{}") || entry.getValue().equals("{ }"))
 .map(Map.Entry::getKey)
 .collect(Collectors.toList());

有没有办法使用 puppycrawl checkstyle 来检查上面的 lambda 表达式是否存在类型?在这种情况下,变量的类型声明是:(final Map.Entry<String, String> entry)

以上是有没有办法检查Lambda变量的显式类型?的全部内容。
THE END
分享
二维码
< <上一篇
下一篇>>