java.util.Set.copyOf()方法的使用及代码示例

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

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

Set.copyOf介绍

暂无

代码示例

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

private Set<String> prefixAndPostfix(String title) {
  for (String separator : GroupTitleUtils.getGroupSeparators()) {
    String[] splittedTitle = title.split(separator);
    if (splittedTitle.length > 1) {
      String prefix = splittedTitle[0];
      String postfix = splittedTitle[splittedTitle.length - 1];
      return Set.copyOf(asList(prefix, postfix));
    }
  }
  return Set.of(title);
}

代码示例来源:origin: com.yahoo.vespa/node-repository

/** @return Nodes of type host, in any state, that have no children with allocation */
  static Set<Node> candidates(NodeList nodes) {
    Map<String, Node> hostsByHostname = nodes.nodeType(NodeType.host)
        .asList().stream()
        .collect(Collectors.toMap(Node::hostname, Function.identity()));

    nodes.asList().stream()
        .filter(node -> node.allocation().isPresent())
        .flatMap(node -> node.parentHostname().stream())
        .distinct()
        .forEach(hostsByHostname::remove);

    return Set.copyOf(hostsByHostname.values());
  }
}

相关文章