java.util.stream.Collectors.toUnmodifiableMap()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(1.1k)|赞(0)|评价(0)|浏览(210)

本文整理了Java中java.util.stream.Collectors.toUnmodifiableMap()方法的一些代码示例,展示了Collectors.toUnmodifiableMap()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Collectors.toUnmodifiableMap()方法的具体详情如下:
包路径:java.util.stream.Collectors
类名称:Collectors
方法名:toUnmodifiableMap

Collectors.toUnmodifiableMap介绍

暂无

代码示例

代码示例来源:origin: moditect/deptective

public DeptectiveOptions(String... args) {
  if (args != null) {
    this.options = Arrays.stream(args)
        .map(o -> o.split("="))
        .collect(Collectors.toUnmodifiableMap(o -> o[0], o -> o[1]));
  }
  else {
    this.options = Collections.emptyMap();
  }
}

代码示例来源:origin: com.github.tornaia/aott-desktop-client-core

public CategorySettings copy() {
  CategorySettings categorySettings = new CategorySettings();
  categorySettings.categories = List.copyOf(categories);
  categorySettings.processToCategoryMap = Map.copyOf(processToCategoryMap);
  categorySettings.nodeToCategoryMap = nodeToCategoryMap
      .entrySet()
      .stream()
      .map(e -> new AbstractMap.SimpleImmutableEntry<>(e.getKey(), Map.copyOf(e.getValue())))
      .collect(Collectors.toUnmodifiableMap(Map.Entry::getKey, Map.Entry::getValue));
  return categorySettings;
}

相关文章