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


Java CollectionUtils.collect方法代码示例

本文整理汇总了Java中org.gradle.util.CollectionUtils.collect方法的典型用法代码示例。如果您正苦于以下问题:Java CollectionUtils.collect方法的具体用法?Java CollectionUtils.collect怎么用?Java CollectionUtils.collect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.gradle.util.CollectionUtils的用法示例。


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

示例1: createAssetsClassLoader

import org.gradle.util.CollectionUtils; //导入方法依赖的package包/类
@Override
protected ClassLoader createAssetsClassLoader(File assetsJar, Iterable<File> assetsDirs, ClassLoader classLoader) {
    Class<?> assetsClassLoaderClass;

    assetsClassLoaderClass = loadClass(classLoader, "play.runsupport.AssetsClassLoader");

    final Class<?> tuple2Class = loadClass(classLoader, "scala.Tuple2");

    List<?> tuples = CollectionUtils.collect(assetsDirs, new Transformer<Object, File>() {
        @Override
        public Object transform(File file) {
            return DirectInstantiator.instantiate(tuple2Class, "public", file);
        }
    });

    ScalaMethod listToScalaSeqMethod = ScalaReflectionUtil.scalaMethod(classLoader, "scala.collection.convert.WrapAsScala", "asScalaBuffer", List.class);
    Object scalaTuples = listToScalaSeqMethod.invoke(tuples);

    return Cast.uncheckedCast(DirectInstantiator.instantiate(assetsClassLoaderClass, classLoader, scalaTuples));
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:21,代码来源:PlayRunAdapterV23X.java

示例2: transform

import org.gradle.util.CollectionUtils; //导入方法依赖的package包/类
@Override
public List<ModelPath> transform(final ModelPath unavailable) {
    Iterable<Suggestion> suggestions = Iterables.transform(availablePaths, new Function<ModelPath, Suggestion>() {
        public Suggestion apply(ModelPath available) {
            int distance = StringUtils.getLevenshteinDistance(unavailable.toString(), available.toString());
            boolean suggest = distance <= Math.min(3, unavailable.toString().length() / 2);
            if (suggest) {
                return new Suggestion(distance, available);
            } else {
                // avoid excess creation of Suggestion objects
                return null;
            }
        }
    });

    suggestions = Iterables.filter(suggestions, REMOVE_NULLS);
    List<Suggestion> sortedSuggestions = CollectionUtils.sort(suggestions);
    return CollectionUtils.collect(sortedSuggestions, Suggestion.EXTRACT_PATH);
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:20,代码来源:ModelPathSuggestionProvider.java

示例3: LocallyAvailableResourceFinderSearchableFileStoreAdapter

import org.gradle.util.CollectionUtils; //导入方法依赖的package包/类
public LocallyAvailableResourceFinderSearchableFileStoreAdapter(final FileStoreSearcher<C> fileStore) {
    super(new Transformer<Factory<List<File>>, C>() {
        public Factory<List<File>> transform(final C criterion) {
            return new Factory<List<File>>() {
                public List<File> create() {
                    Set<? extends LocallyAvailableResource> entries = fileStore.search(criterion);
                    return CollectionUtils.collect(entries, new ArrayList<File>(entries.size()), new Transformer<File, LocallyAvailableResource>() {
                        public File transform(LocallyAvailableResource original) {
                            return original.getFile();
                        }
                    });
                }
            };
        }
    });
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:17,代码来源:LocallyAvailableResourceFinderSearchableFileStoreAdapter.java

示例4: toProviderInternalJvmTestRequest

import org.gradle.util.CollectionUtils; //导入方法依赖的package包/类
private static List<InternalJvmTestRequest> toProviderInternalJvmTestRequest(Collection<InternalJvmTestRequest> internalJvmTestRequests, Collection<String> testClassNames) {
    // handle consumer < 2.7
    if(internalJvmTestRequests.isEmpty()){
        return CollectionUtils.collect(testClassNames, new Transformer<InternalJvmTestRequest, String>() {
            @Override
            public InternalJvmTestRequest transform(String testClass) {
                return new ProviderInternalJvmTestRequest(testClass, null);
            }
        });
    } else {
        return CollectionUtils.collect(internalJvmTestRequests, new Transformer<InternalJvmTestRequest, InternalJvmTestRequest>() {
            @Override
            public InternalJvmTestRequest transform(InternalJvmTestRequest internalTestMethod) {
                return new ProviderInternalJvmTestRequest(internalTestMethod.getClassName(), internalTestMethod.getMethodName());
            }
        });
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:19,代码来源:TestExecutionRequestAction.java

示例5: resolveAndFilterSourceFiles

import org.gradle.util.CollectionUtils; //导入方法依赖的package包/类
private void resolveAndFilterSourceFiles(final GroovyJavaJointCompileSpec spec) {
    final List<String> fileExtensions = CollectionUtils.collect(spec.getGroovyCompileOptions().getFileExtensions(), new Transformer<String, String>() {
        @Override
        public String transform(String extension) {
            return '.' + extension;
        }
    });
    FileCollection filtered = spec.getSource().filter(new Spec<File>() {
        public boolean isSatisfiedBy(File element) {
            for (String fileExtension : fileExtensions) {
                if (hasExtension(element, fileExtension)) {
                    return true;
                }
            }
            return false;
        }
    });

    spec.setSource(new SimpleFileCollection(filtered.getFiles()));
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:21,代码来源:NormalizingGroovyCompiler.java

示例6: locateAllVisualStudioVersions

import org.gradle.util.CollectionUtils; //导入方法依赖的package包/类
@Override
public List<SearchResult> locateAllVisualStudioVersions() {
    initializeVisualStudioInstalls();

    List<VisualStudioInstall> sortedInstalls = CollectionUtils.sort(foundInstalls.values(), new Comparator<VisualStudioInstall>() {
        @Override
        public int compare(VisualStudioInstall o1, VisualStudioInstall o2) {
            return o2.getVersion().compareTo(o1.getVersion());
        }
    });

    if (sortedInstalls.isEmpty()) {
        return Lists.newArrayList((SearchResult)new InstallNotFound("Could not locate a Visual Studio installation, using the Windows registry and system path."));
    } else {
        return CollectionUtils.collect(sortedInstalls, new Transformer<SearchResult, VisualStudioInstall>() {
            @Override
            public SearchResult transform(VisualStudioInstall visualStudioInstall) {
                return new InstallFound(visualStudioInstall);
            }
        });
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:23,代码来源:DefaultVisualStudioLocator.java

示例7: handleWatchKey

import org.gradle.util.CollectionUtils; //导入方法依赖的package包/类
private List<FileWatcherEvent> handleWatchKey(WatchKey watchKey) {
    final Path watchedPath = (Path) watchKey.watchable();
    Transformer<FileWatcherEvent, WatchEvent<?>> watchEventTransformer = new Transformer<FileWatcherEvent, WatchEvent<?>>() {
        @Override
        public FileWatcherEvent transform(WatchEvent<?> event) {
            WatchEvent.Kind kind = event.kind();
            File file = null;
            if (kind.type() == Path.class) {
                WatchEvent<Path> ev = Cast.uncheckedCast(event);
                file = watchedPath.resolve(ev.context()).toFile();
            }
            return toEvent(kind, file);
        }
    };

    List<WatchEvent<?>> watchEvents = watchKey.pollEvents();
    watchKey.reset();
    if (watchEvents.isEmpty()) {
        return Collections.singletonList(FileWatcherEvent.delete(watchedPath.toFile()));
    } else {
        return CollectionUtils.collect(watchEvents, watchEventTransformer);
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:24,代码来源:WatchServicePoller.java

示例8: getEnabledInputReports

import org.gradle.util.CollectionUtils; //导入方法依赖的package包/类
@Internal
private Set<Report> getEnabledInputReports() {
    Set<NamedDomainObjectSet<? extends Report>> enabledReportSets = CollectionUtils.collect(aggregated, new Transformer<NamedDomainObjectSet<? extends Report>, Reporting<? extends ReportContainer<?>>>() {
        public NamedDomainObjectSet<? extends Report> transform(Reporting<? extends ReportContainer<?>> reporting) {
            return reporting.getReports().getEnabled();
        }
    });
    return new LinkedHashSet<Report>(CollectionUtils.flattenCollections(Report.class, enabledReportSets));
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:10,代码来源:GenerateBuildDashboard.java

示例9: getFilesWithoutCreating

import org.gradle.util.CollectionUtils; //导入方法依赖的package包/类
public Set<File> getFilesWithoutCreating() {
    return CollectionUtils.collect(elements.keySet(), new Transformer<File, RelativePath>() {
        @Override
        public File transform(RelativePath relativePath) {
            return createFileInstance(relativePath);
        }
    });
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:9,代码来源:MapFileTree.java

示例10: createInsight

import org.gradle.util.CollectionUtils; //导入方法依赖的package包/类
private List createInsight(ModuleIdentifier module, final Configuration configuration) {
    final Spec<DependencyResult> dependencySpec = new StrictDependencyResultSpec(module);

    ResolutionResult result = configuration.getIncoming().getResolutionResult();
    final Set<DependencyResult> selectedDependencies = new LinkedHashSet<DependencyResult>();

    result.allDependencies(new Action<DependencyResult>() {
        @Override
        public void execute(DependencyResult it) {
            if (dependencySpec.isSatisfiedBy(it)) {
                selectedDependencies.add(it);
            }
        }
    });

    Collection<RenderableDependency> sortedDeps = new DependencyInsightReporter().prepare(selectedDependencies, versionSelectorScheme, versionComparator);
    return CollectionUtils.collect(sortedDeps, new Transformer<Object, RenderableDependency>() {
        @Override
        public Object transform(RenderableDependency dependency) {
            String name = replaceArrow(dependency.getName());
            LinkedHashMap<String, Object> map = new LinkedHashMap<String, Object>(5);
            map.put("name", replaceArrow(dependency.getName()));
            map.put("description", dependency.getDescription());
            map.put("resolvable", dependency.getResolutionState());
            map.put("hasConflict", !name.equals(dependency.getName()));
            map.put("children", createInsightDependencyChildren(dependency, new HashSet<Object>(), configuration));
            return map;
        }
    });
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:31,代码来源:JsonProjectDependencyRenderer.java

示例11: getAll

import org.gradle.util.CollectionUtils; //导入方法依赖的package包/类
public List<GradleDistribution> getAll() {
    if (distributions == null) {
        distributions = CollectionUtils.collect(getProperties().getProperty("versions").split("\\s+"), new Transformer<GradleDistribution, String>() {
            public GradleDistribution transform(String version) {
                return buildContext.distribution(version);
            }
        });
    }
    return distributions;
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:11,代码来源:ReleasedVersionDistributions.java

示例12: generate

import org.gradle.util.CollectionUtils; //导入方法依赖的package包/类
@TaskAction
public void generate() {
    Properties properties = new Properties();

    if (!getPluginClasspath().isEmpty()) {
        List<String> paths = CollectionUtils.collect(getPluginClasspath(), new Transformer<String, File>() {
            @Override
            public String transform(File file) {
                return file.getAbsolutePath().replaceAll("\\\\", "/");
            }
        });
        StringBuilder implementationClasspath = new StringBuilder();
        Joiner.on(File.pathSeparator).appendTo(implementationClasspath, paths);
        properties.setProperty(IMPLEMENTATION_CLASSPATH_PROP_KEY, implementationClasspath.toString());

        // As these files are inputs into this task, they have just been snapshotted by the task up-to-date checking.
        // We should be reusing those persistent snapshots to avoid reading into memory again.
        HashClassPathSnapshotter classPathSnapshotter = new HashClassPathSnapshotter(new DefaultFileHasher());
        String hash = classPathSnapshotter.snapshot(new DefaultClassPath(getPluginClasspath())).getStrongHash().toString();
        properties.setProperty(IMPLEMENTATION_CLASSPATH_HASH_PROP_KEY, hash);
    }

    File outputFile = new File(getOutputDirectory(), METADATA_FILE_NAME);

    try {
        OutputStream outputStream = new BufferedOutputStream(new FileOutputStream(outputFile));
        GUtil.savePropertiesNoDateComment(properties, outputStream);
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:32,代码来源:PluginUnderTestMetadata.java

示例13: createNow

import org.gradle.util.CollectionUtils; //导入方法依赖的package包/类
private Set<MavenProject> createNow(Settings settings, File pomFile) throws PlexusContainerException, PlexusConfigurationException, ComponentLookupException, MavenExecutionRequestPopulationException, ProjectBuildingException {
    ContainerConfiguration containerConfiguration = new DefaultContainerConfiguration()
            .setClassWorld(new ClassWorld("plexus.core", ClassWorld.class.getClassLoader()))
            .setName("mavenCore");

    DefaultPlexusContainer container = new DefaultPlexusContainer(containerConfiguration);
    ProjectBuilder builder = container.lookup(ProjectBuilder.class);
    MavenExecutionRequest executionRequest = new DefaultMavenExecutionRequest();
    final Properties properties = new Properties();
    properties.putAll(SystemProperties.getInstance().asMap());
    executionRequest.setSystemProperties(properties);
    MavenExecutionRequestPopulator populator = container.lookup(MavenExecutionRequestPopulator.class);
    populator.populateFromSettings(executionRequest, settings);
    populator.populateDefaults(executionRequest);
    ProjectBuildingRequest buildingRequest = executionRequest.getProjectBuildingRequest();
    buildingRequest.setProcessPlugins(false);
    MavenProject mavenProject = builder.build(pomFile, buildingRequest).getProject();
    Set<MavenProject> reactorProjects = new LinkedHashSet<MavenProject>();

    //TODO adding the parent project first because the converter needs it this way ATM. This is oversimplified.
    //the converter should not depend on the order of reactor projects.
    //we should add coverage for nested multi-project builds with multiple parents.
    reactorProjects.add(mavenProject);
    List<ProjectBuildingResult> allProjects = builder.build(ImmutableList.of(pomFile), true, buildingRequest);
    CollectionUtils.collect(allProjects, reactorProjects, new Transformer<MavenProject, ProjectBuildingResult>() {
        public MavenProject transform(ProjectBuildingResult original) {
            return original.getProject();
        }
    });

    MavenExecutionResult result = new DefaultMavenExecutionResult();
    result.setProject(mavenProject);
    RepositorySystemSession repoSession = new DefaultRepositorySystemSession();
    MavenSession session = new MavenSession(container, repoSession, executionRequest, result);
    session.setCurrentProject(mavenProject);

    return reactorProjects;
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:39,代码来源:MavenProjectsCreator.java

示例14: resolveGraph

import org.gradle.util.CollectionUtils; //导入方法依赖的package包/类
public void resolveGraph(ConfigurationInternal configuration, ResolverResults results) {
    List<ResolutionAwareRepository> resolutionAwareRepositories = CollectionUtils.collect(repositories, Transformers.cast(ResolutionAwareRepository.class));
    StoreSet stores = storeFactory.createStoreSet();

    BinaryStore oldModelStore = stores.nextBinaryStore();
    Store<TransientConfigurationResults> oldModelCache = stores.oldModelCache();
    TransientConfigurationResultsBuilder oldTransientModelBuilder = new TransientConfigurationResultsBuilder(oldModelStore, oldModelCache);
    DefaultResolvedConfigurationBuilder oldModelBuilder = new DefaultResolvedConfigurationBuilder(oldTransientModelBuilder);
    ResolvedConfigurationDependencyGraphVisitor oldModelVisitor = new ResolvedConfigurationDependencyGraphVisitor(oldModelBuilder);

    BinaryStore newModelStore = stores.nextBinaryStore();
    Store<ResolvedComponentResult> newModelCache = stores.newModelCache();
    StreamingResolutionResultBuilder newModelBuilder = new StreamingResolutionResultBuilder(newModelStore, newModelCache);

    ResolvedLocalComponentsResultGraphVisitor localComponentsVisitor = new ResolvedLocalComponentsResultGraphVisitor();

    DefaultResolvedArtifactsBuilder artifactsBuilder = new DefaultResolvedArtifactsBuilder(buildProjectDependencies);
    FileDependencyCollectingGraphVisitor fileDependencyVisitor = new FileDependencyCollectingGraphVisitor();

    DependencyGraphVisitor graphVisitor = new CompositeDependencyGraphVisitor(oldModelVisitor, newModelBuilder, localComponentsVisitor, fileDependencyVisitor);
    DependencyArtifactsVisitor artifactsVisitor = new CompositeDependencyArtifactsVisitor(oldModelVisitor, artifactsBuilder);

    resolver.resolve(configuration, resolutionAwareRepositories, metadataHandler, Specs.<DependencyMetadata>satisfyAll(), graphVisitor, artifactsVisitor, attributesSchema);

    ArtifactTransformer transformer = new ArtifactTransformer(configuration.getResolutionStrategy(), attributesSchema);
    VisitedArtifactsResults artifactsResults = artifactsBuilder.complete();
    results.graphResolved(newModelBuilder.complete(), localComponentsVisitor, new BuildDependenciesOnlyVisitedArtifactSet(artifactsResults, fileDependencyVisitor, transformer));

    results.retainState(new ArtifactResolveState(oldModelBuilder.complete(), artifactsResults, fileDependencyVisitor, oldTransientModelBuilder));
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:31,代码来源:DefaultConfigurationResolver.java

示例15: createConfigurations

import org.gradle.util.CollectionUtils; //导入方法依赖的package包/类
private List<Map> createConfigurations(Project project) {
    Iterable<Configuration> configurations = project.getConfigurations();
    return CollectionUtils.collect(configurations, new Transformer<Map, Configuration>() {
        @Override
        public Map transform(Configuration configuration) {
            LinkedHashMap<String, Object> map = new LinkedHashMap<String, Object>(4);
            map.put("name", configuration.getName());
            map.put("description", configuration.getDescription());
            map.put("dependencies", createDependencies(configuration));
            map.put("moduleInsights", createModuleInsights(configuration));
            return map;
        }

    });
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:16,代码来源:JsonProjectDependencyRenderer.java


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