当前位置: 首页>>代码示例>>Java>>正文


Java MoreCollectors类代码示例

本文整理汇总了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;未经允许,请勿转载。