在 Cactoos Joined 上使用多个 Iterables 抛出警告 class
Warning thrown by using multiple Iterables on Cactoos Joined class
重构 Rultor to use Cactoos instead of Guava, I’m having an issue with DockerRun
class 时,在 envs
方法中。
当前重构结果为:
final List<String> entries = new LinkedList<>();
for (final Entry<String, String> ent : extra.entrySet()) {
entries.add(
String.format(
"%s=%s", ent.getKey(), ent.getValue()
)
);
}
return new Joined<>(
DockerRun.envs(this.profile.read(), "/p/entry[@key='env']"),
DockerRun.envs(this.node(), "entry[@key='env']"),
new ListOf<>(entries)
);
当我构建项目时,抛出以下警告消息:
[WARNING] (...)rultor/src/main/java/com/rultor/agents/req/DockerRun.java:
[132,16] unchecked generic array creation for varargs
parameter of type java.lang.Iterable<java.lang.String>[]
请注意,在我的例子中,第 132 行是 new Joined<>(
的行
在搜索 SO 之后,我发现了类似的问题,例如 one,但没有关于如何修复我的案例中的警告消息的提示。
所以我的问题是,如何在没有收到警告消息的情况下仍然连接可迭代对象,但仍然使用 Cactoos。
试试这样写:
new Joined<String>(
重构 Rultor to use Cactoos instead of Guava, I’m having an issue with DockerRun
class 时,在 envs
方法中。
当前重构结果为:
final List<String> entries = new LinkedList<>();
for (final Entry<String, String> ent : extra.entrySet()) {
entries.add(
String.format(
"%s=%s", ent.getKey(), ent.getValue()
)
);
}
return new Joined<>(
DockerRun.envs(this.profile.read(), "/p/entry[@key='env']"),
DockerRun.envs(this.node(), "entry[@key='env']"),
new ListOf<>(entries)
);
当我构建项目时,抛出以下警告消息:
[WARNING] (...)rultor/src/main/java/com/rultor/agents/req/DockerRun.java:
[132,16] unchecked generic array creation for varargs
parameter of type java.lang.Iterable<java.lang.String>[]
请注意,在我的例子中,第 132 行是 new Joined<>(
在搜索 SO 之后,我发现了类似的问题,例如 one,但没有关于如何修复我的案例中的警告消息的提示。
所以我的问题是,如何在没有收到警告消息的情况下仍然连接可迭代对象,但仍然使用 Cactoos。
试试这样写:
new Joined<String>(