示例#1
0
 private TreeSnapshot createTreeSnapshot(
     final FileSnapshotter fileSnapshotter, final StringInterner stringInterner) {
   final Collection<FileSnapshotWithKey> fileSnapshots =
       CollectionUtils.collect(
           getEntries(),
           new Transformer<FileSnapshotWithKey, FileTreeElement>() {
             @Override
             public FileSnapshotWithKey transform(FileTreeElement fileTreeElement) {
               String absolutePath =
                   getInternedAbsolutePath(fileTreeElement.getFile(), stringInterner);
               IncrementalFileSnapshot incrementalFileSnapshot;
               if (fileTreeElement.isDirectory()) {
                 incrementalFileSnapshot = DirSnapshot.getInstance();
               } else {
                 incrementalFileSnapshot =
                     new FileHashSnapshot(
                         fileSnapshotter.snapshot(fileTreeElement).getHash(),
                         fileTreeElement.getLastModified());
               }
               return new FileSnapshotWithKey(absolutePath, incrementalFileSnapshot);
             }
           });
   if (missingFiles != null) {
     for (File file : missingFiles) {
       fileSnapshots.add(
           new FileSnapshotWithKey(
               getInternedAbsolutePath(file, stringInterner), MissingFileSnapshot.getInstance()));
     }
   }
   return new DefaultTreeSnapshot(fileSnapshots, shareable, nextId);
 }
示例#2
0
 public Set<File> getFilesWithoutCreating() {
   return CollectionUtils.collect(
       elements.keySet(),
       new Transformer<File, RelativePath>() {
         @Override
         public File transform(RelativePath relativePath) {
           return createFileInstance(relativePath);
         }
       });
 }
 public List<ExtractedModelRule> getRules() {
   return CollectionUtils.collect(
       rules,
       new Transformer<ExtractedModelRule, ExtractedRuleDetails>() {
         @Override
         public ExtractedModelRule transform(ExtractedRuleDetails extractedRuleDetails) {
           return extractedRuleDetails.rule;
         }
       });
 }
 private String describeHandlers() {
   String desc =
       Joiner.on(", ")
           .join(
               CollectionUtils.collect(
                   handlers,
                   new Transformer<String, MethodModelRuleExtractor>() {
                     public String transform(MethodModelRuleExtractor original) {
                       return original.getDescription();
                     }
                   }));
   return "[" + desc + "]";
 }
  public void determineExecutionPlan() {
    List<TaskInfo> nodeQueue =
        CollectionUtils.collect(
            new ArrayList<Task>(entryTasks),
            new Transformer<TaskInfo, Task>() {
              public TaskInfo transform(Task original) {
                return graph.getNode(original);
              }
            });

    Set<TaskInfo> visitingNodes = new HashSet<TaskInfo>();
    while (!nodeQueue.isEmpty()) {
      TaskInfo taskNode = nodeQueue.get(0);
      boolean filtered = !filter.isSatisfiedBy(taskNode.getTask());
      if (filtered) {
        taskNode.setRequired(false);
      }

      if (!taskNode.getRequired() || executionPlan.containsKey(taskNode.getTask())) {
        nodeQueue.remove(0);
        continue;
      }

      if (visitingNodes.add(taskNode)) {
        // Have not seen this task before - add its dependencies to the head of the queue and leave
        // this
        // task in the queue
        ArrayList<TaskInfo> dependsOnTasks = new ArrayList<TaskInfo>();
        addAllReversed(dependsOnTasks, taskNode.getHardSuccessors());
        addAllReversed(dependsOnTasks, taskNode.getSoftSuccessors());
        for (TaskInfo dependsOnTask : dependsOnTasks) {
          if (visitingNodes.contains(dependsOnTask)) {
            throw new CircularReferenceException(
                String.format(
                    "Circular dependency between tasks. Cycle includes [%s, %s].",
                    taskNode.getTask(), dependsOnTask.getTask()));
          }
          nodeQueue.add(0, dependsOnTask);
        }
      } else {
        // Have visited this task's dependencies - add it to the end of the plan
        nodeQueue.remove(0);
        visitingNodes.remove(taskNode);
        executionPlan.put(taskNode.getTask(), taskNode);
      }
    }
  }
示例#6
0
  private String compilerConfig(String action, String... args) {
    String quotedArgs =
        CollectionUtils.join(",", CollectionUtils.collect(args, new SingleQuotingTransformer()));
    StringBuilder builder = new StringBuilder();
    for (String plugin : getPluginList()) {
      String compilerPrefix = getCompilerPrefix(plugin);
      if (compilerPrefix == null) {
        continue;
      }
      builder
          .append(compilerPrefix)
          .append("Compiler.")
          .append(action)
          .append(" ")
          .append(quotedArgs)
          .append("\n");
    }

    return builder.toString();
  }
 public ClassLoader createIsolatedClassLoader(Iterable<URI> uris) {
   return doCreateIsolatedClassLoader(CollectionUtils.collect(uris, Transformers.toURL()));
 }