• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java MoreCollectors类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.google.common.collect.MoreCollectors的典型用法代码示例。如果您正苦于以下问题:Java MoreCollectors类的具体用法?Java MoreCollectors怎么用?Java MoreCollectors使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



MoreCollectors类属于com.google.common.collect包,在下文中一共展示了MoreCollectors类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: readFromPath

import com.google.common.collect.MoreCollectors; //导入依赖的package包/类
/** Returns the application info read from either an app folder or ipa archive */
public static IosAppInfo readFromPath(Path ipaOrAppPath) throws IOException {
  NSObject plistDict;
  if (Files.isDirectory(ipaOrAppPath)) {
    plistDict = PlistParser.fromPath(ipaOrAppPath.resolve("Info.plist"));
  } else {
    try (FileSystem ipaFs = FileSystems.newFileSystem(ipaOrAppPath, null)) {
      Path appPath =
          MoreFiles.listFiles(ipaFs.getPath("Payload"))
              .stream()
              // Can't use Files.isDirectory, because no entry is a "directory" in a zip.
              .filter(e -> e.toString().endsWith(".app/"))
              .collect(MoreCollectors.onlyElement());
      plistDict = PlistParser.fromPath(appPath.resolve("Info.plist"));
    }
  }
  return readFromPlistDictionary((NSDictionary) plistDict);
}
 
开发者ID:google,项目名称:ios-device-control,代码行数:19,代码来源:IosAppInfo.java


示例2: toModel

import com.google.common.collect.MoreCollectors; //导入依赖的package包/类
private static IosModel toModel(String deviceType) throws IOException {
  checkArgument(deviceType.matches("[-\\w]*"));
  Path profileInfoBasePath =
      Paths.get(
          "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/"
              + "Developer/Library/CoreSimulator/Profiles/DeviceTypes");
  Path deviceTypePath =
      MoreFiles.listFiles(profileInfoBasePath)
          .stream()
          // The directory name that matches a given device type is the same as the name from the
          // device.plist file, with the hyphens replaced with spaces, hyphens, parentheses or
          // periods
          .filter(
              p -> MoreFiles.getNameWithoutExtension(p).replaceAll("\\W", "-").equals(deviceType))
          .collect(MoreCollectors.onlyElement());
  String rawProductName = MoreFiles.getNameWithoutExtension(deviceTypePath);
  String productName = GENERATION_PATTERN.matcher(rawProductName).replaceFirst("$1");

  Path profilePath = deviceTypePath.resolve("Contents/Resources/profile.plist");
  NSDictionary profileDict = (NSDictionary) PlistParser.fromPath(profilePath);
  String identifier = profileDict.get("modelIdentifier").toString();

  NSArray supportedArchs = (NSArray) profileDict.get("supportedArchs");
  // The supported architecture can either be just i386 or i386 and x86_64. The
  // actual architecture will be x86_64 if its supported, or i386 otherwise.
  Architecture architecture =
      supportedArchs.containsObject(Architecture.X86_64.toString())
          ? Architecture.X86_64
          : Architecture.I386;
  return IosModel.builder()
      .identifier(identifier)
      .productName(productName)
      .architecture(architecture)
      .build();
}
 
开发者ID:google,项目名称:ios-device-control,代码行数:36,代码来源:SimulatorDeviceHost.java


示例3: userApps

import com.google.common.collect.MoreCollectors; //导入依赖的package包/类
private ImmutableSet<IosAppInfo> userApps() throws IOException {
  Path appPath =
      Paths.get(
          System.getProperty("user.home"),
          "Library/Developer/CoreSimulator/Devices",
          udid,
          "data/Containers/Bundle/Application");
  if (!Files.exists(appPath)) {
    return ImmutableSet.of();
  }
  try {
    return MoreFiles.listFiles(appPath)
        .stream()
        .map(
            p ->
                tunnel(
                    () ->
                        MoreFiles.listFiles(p)
                            .stream()
                            .filter(a -> MoreFiles.getFileExtension(a).equals("app"))
                            .collect(MoreCollectors.onlyElement())))
        .map(a -> tunnel(() -> IosAppInfo.readFromPath(a)))
        .collect(toImmutableSet());
  } catch (TunnelException e) {
    throw e.getCauseAs(IOException.class);
  }
}
 
开发者ID:google,项目名称:ios-device-control,代码行数:28,代码来源:SimulatorDeviceImpl.java


示例4: getHostNode

import com.google.common.collect.MoreCollectors; //导入依赖的package包/类
protected NodeTemplate getHostNode(DirectedMultigraph<NodeTemplate, RelationshipTemplate> graph,
    NodeTemplate taskNode) {
  return graph
      .incomingEdgesOf(taskNode)
      .stream()
      .filter(
          relationship -> HOST_CAPABILITY_NAME.equals(relationship.getTargetedCapabilityName()))
      .map(graph::getEdgeSource)
      // if more than 1 node is present -> IllegalArgumentException
      .collect(MoreCollectors.toOptional())
      .orElseThrow(() -> new IllegalArgumentException(
          String.format("No hosting node provided for node <%s>", taskNode.getName())));
}
 
开发者ID:indigo-dc,项目名称:orchestrator,代码行数:14,代码来源:AbstractMesosDeploymentService.java


示例5: typeParameterInList

import com.google.common.collect.MoreCollectors; //导入依赖的package包/类
private TypeParameterTree typeParameterInList(
    List<? extends TypeParameterTree> typeParameters, TypeVariableSymbol v) {
  return typeParameters
      .stream()
      .filter(t -> t.getName().contentEquals(v.name))
      .collect(MoreCollectors.onlyElement());
}
 
开发者ID:google,项目名称:error-prone,代码行数:8,代码来源:TypeParameterShadowing.java


示例6: finalizeDeploy

import com.google.common.collect.MoreCollectors; //导入依赖的package包/类
@Override
public void finalizeDeploy(DeploymentMessage deploymentMessage) {
  Deployment deployment = getDeployment(deploymentMessage);

  ArchiveRoot ar = toscaService
      .prepareTemplate(deployment.getTemplate(), deployment.getParameters());

  Map<String, OutputDefinition> outputs = Optional
      .ofNullable(ar.getTopology())
      .map(Topology::getOutputs)
      .orElseGet(HashMap::new);
  if (!outputs.isEmpty()) {
    String groupId = deployment.getId();
    Group group = getMarathonClient(deployment).getGroup(groupId);

    Map<String, NodeTemplate> nodes = Optional
        .ofNullable(ar.getTopology())
        .map(Topology::getNodeTemplates)
        .orElseGet(HashMap::new);

    DirectedMultigraph<NodeTemplate, RelationshipTemplate> graph =
        toscaService.buildNodeGraph(nodes, false);

    TopologicalOrderIterator<NodeTemplate, RelationshipTemplate> orderIterator =
        new TopologicalOrderIterator<>(graph);

    List<NodeTemplate> orderedMarathonApps = CommonUtils
        .iteratorToStream(orderIterator)
        .filter(node -> toscaService.isOfToscaType(node, ToscaConstants.Nodes.MARATHON))
        .collect(Collectors.toList());

    MarathonProperties marathonProperties =
        marathonClientFactory.getFrameworkProperties(deployment);
    RuntimeProperties runtimeProperties = new RuntimeProperties();
    for (NodeTemplate marathonNode : orderedMarathonApps) {

      runtimeProperties.put(marathonProperties.getLoadBalancerIps(), marathonNode.getName(),
          "load_balancer_ips");

      List<Integer> ports = group
          .getApps()
          .stream()
          .filter(
              app -> app.getId().endsWith("/" + marathonNode.getName()))
          .collect(MoreCollectors.toOptional())
          .map(App::getPorts)
          .orElseGet(ArrayList::new);

      NodeTemplate hostNode = getHostNode(graph, marathonNode);
      for (int i = 0; i < ports.size(); ++i) {
        runtimeProperties.put(ports.get(i), hostNode.getName(), "host",
            "publish_ports", String.valueOf(i), "target");
      }
    }
    deployment.setOutputs(indigoInputsPreProcessorService.processOutputs(ar,
        deployment.getParameters(), runtimeProperties));
  }
  super.finalizeDeploy(deploymentMessage);
}
 
开发者ID:indigo-dc,项目名称:orchestrator,代码行数:60,代码来源:MarathonServiceImpl.java



注:本文中的com.google.common.collect.MoreCollectors类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ResponseTypeValues类代码示例发布时间:2022-05-22
下一篇:
Java ProvidesDatabaseConnectionInformation类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap