如何将以下方法转换为Java 8流图?

问题描述 投票:-7回答:1

我需要在Java 8 Map API中替换此函数。

final List<String> x;
x.stream().forEach(id -> isPossibleIdentifier(K, id));

isPossibleIdentifier函数,

  public void isPossibleIdentifier(final String name, final String value)
  {
    isNullOrEmpty(name, value);

    if (!value.matches(NUMBER_FORMAT))
    {
      throw getException(String.format("Invalid format", name));
    }
  }

此外,我需要专家帮助将其转换为x.strem.map()

java java-8 stream java-stream
1个回答
-2
投票

要想出主意,我想你需要这样的东西,

 x.strem().map(id -> 
 {
 return isPossibleIdentifier(K, id)
 };
 ).forEach(System.out::println);
© www.soinside.com 2019 - 2024. All rights reserved.