本文整理汇总了Java中org.gradle.util.CollectionUtils.sort方法的典型用法代码示例。如果您正苦于以下问题:Java CollectionUtils.sort方法的具体用法?Java CollectionUtils.sort怎么用?Java CollectionUtils.sort使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.gradle.util.CollectionUtils
的用法示例。
在下文中一共展示了CollectionUtils.sort方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: visitTasks
import org.gradle.util.CollectionUtils; //导入方法依赖的package包/类
private static <P, T> List<T> visitTasks(Visitor<P, T> visitor, ProjectAndTaskFilter filter, ProjectView project,
int startingIndex, P userProjectObject, Comparator<TaskView> taskSorter) {
List<T> taskObjects = new ArrayList<T>();
List<TaskView> tasks = CollectionUtils.sort(project.getTasks(), taskSorter); //make a copy because we're going to sort them
Iterator<TaskView> iterator = tasks.iterator();
int index = startingIndex;
while (iterator.hasNext()) {
TaskView task = iterator.next();
if (filter.doesAllowTask(task)) {
T taskObject = visitor.visitTask(task, index, project, userProjectObject);
taskObjects.add(taskObject);
}
index++;
}
return taskObjects;
}
示例3: 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);
}
});
}
}
示例4: AbstractCompatibilityTestRunner
import org.gradle.util.CollectionUtils; //导入方法依赖的package包/类
private AbstractCompatibilityTestRunner(Class<?> target, String versionStr) {
super(target);
validateTestName(target);
previous = new ArrayList<GradleDistribution>();
final ReleasedVersionDistributions releasedVersions = new ReleasedVersionDistributions(buildContext);
if (versionStr.equals("latest")) {
implicitVersion = true;
addVersionIfCompatibleWithJvmAndOs(releasedVersions.getMostRecentFinalRelease());
} else if (versionStr.equals("all")) {
implicitVersion = true;
List<GradleDistribution> previousVersionsToTest = choosePreviousVersionsToTest(releasedVersions);
for (GradleDistribution previousVersion : previousVersionsToTest) {
addVersionIfCompatibleWithJvmAndOs(previousVersion);
}
} else if (versionStr.matches("^\\d.*$")) {
implicitVersion = false;
String[] versions = versionStr.split(",");
List<GradleVersion> gradleVersions = CollectionUtils.sort(collect(Arrays.asList(versions), new Transformer<GradleVersion, String>() {
public GradleVersion transform(String versionString) {
return GradleVersion.version(versionString);
}
}), Collections.reverseOrder());
inject(previous, gradleVersions, new Action<InjectionStep<List<GradleDistribution>, GradleVersion>>() {
public void execute(InjectionStep<List<GradleDistribution>, GradleVersion> step) {
GradleDistribution distribution = releasedVersions.getDistribution(step.getItem());
if (distribution == null) {
throw new RuntimeException("Gradle version '" + step.getItem().getVersion() + "' is not a valid testable released version");
}
step.getTarget().add(distribution);
}
});
} else {
throw new RuntimeException("Invalid value for " + VERSIONS_SYSPROP_NAME + " system property: " + versionStr + "(valid values: 'all', 'latest' or comma separated list of versions)");
}
}
示例5: uniqueRecentDaemonStopEvents
import org.gradle.util.CollectionUtils; //导入方法依赖的package包/类
public static List<DaemonStopEvent> uniqueRecentDaemonStopEvents(final List<DaemonStopEvent> stopEvents) {
final Set<Long> uniqueStoppedPids = new HashSet<Long>(stopEvents.size());
final List<DaemonStopEvent> recentStopEvents = new ArrayList<DaemonStopEvent>(stopEvents.size());
final List<DaemonStopEvent> sortedEvents = CollectionUtils.sort(stopEvents, new Comparator<DaemonStopEvent>() {
@Override
public int compare(DaemonStopEvent event1, DaemonStopEvent event2) {
if (event1.getStatus() != null && event2.getStatus() == null) {
return -1;
} else if (event1.getStatus() == null && event2.getStatus() != null) {
return 1;
} else if (event1.getStatus() != null && event2.getStatus() != null) {
return event2.getStatus().compareTo(event1.getStatus());
}
return 0;
}
});
// User likely doesn't care about daemons that stopped a long time ago
for (DaemonStopEvent event : sortedEvents) {
Long pid = event.getPid();
if (event.occurredInLastHours(RECENTLY) && !uniqueStoppedPids.contains(pid)) {
// We can only determine if two DaemonStopEvent point at the same daemon if we know the PIDs
if (pid != null) {
uniqueStoppedPids.add(pid);
}
recentStopEvents.add(event);
}
}
return recentStopEvents;
}
示例6: visitProjects
import org.gradle.util.CollectionUtils; //导入方法依赖的package包/类
private static <P, T> List<P> visitProjects(Visitor<P, T> visitor, ProjectAndTaskFilter filter,
List<ProjectView> sourceProjects, P parentProjectObject, Comparator<ProjectView> projectSorter, Comparator<TaskView> taskSorter) {
List<P> projectObjects = new ArrayList<P>();
sourceProjects = CollectionUtils.sort(sourceProjects, projectSorter); //make a copy because we're going to sort them.
Iterator<ProjectView> iterator = sourceProjects.iterator();
int index = 0;
while (iterator.hasNext()) {
ProjectView project = iterator.next();
if (filter.doesAllowProject(project)) {
P userProjectObject = visitor.visitProject(project, index, parentProjectObject);
projectObjects.add(userProjectObject);
//visit sub projects
List<P> subProjectObjects = visitProjects(visitor, filter, project.getSubProjects(), userProjectObject, projectSorter, taskSorter);
//visit tasks. Notice that we pass in the number of subprojects as a starting index. This is so they'll come afterwards.
List<T> taskObjects = visitTasks(visitor, filter, project, subProjectObjects.size(), userProjectObject, taskSorter);
visitor.completedVisitingProject(userProjectObject, subProjectObjects, taskObjects);
}
index++;
}
return projectObjects;
}
示例7: sortSourceSetsAsPerUsualConvention
import org.gradle.util.CollectionUtils; //导入方法依赖的package包/类
private List<SourceSet> sortSourceSetsAsPerUsualConvention(Iterable<SourceSet> sourceSets) {
return CollectionUtils.sort(sourceSets, new Comparator<SourceSet>() {
@Override
public int compare(SourceSet left, SourceSet right) {
return toComparable(left).compareTo(toComparable(right));
}
});
}
示例8: sortSourceDirsAsPerUsualConvention
import org.gradle.util.CollectionUtils; //导入方法依赖的package包/类
private List<DirectoryTree> sortSourceDirsAsPerUsualConvention(Iterable<DirectoryTree> sourceDirs) {
return CollectionUtils.sort(sourceDirs, new Comparator<DirectoryTree>() {
@Override
public int compare(DirectoryTree left, DirectoryTree right) {
return toComparable(left).compareTo(toComparable(right));
}
});
}
示例9: getOptions
import org.gradle.util.CollectionUtils; //导入方法依赖的package包/类
public List<OptionDescriptor> getOptions(Object target) {
final Class<?> targetClass = target.getClass();
Map<String, OptionDescriptor> options = new HashMap<String, OptionDescriptor>();
if (!cachedOptionElements.containsKey(targetClass)) {
loadClassDescriptorInCache(target);
}
for (OptionElement optionElement : cachedOptionElements.get(targetClass)) {
JavaMethod<Object, Collection> optionValueMethod = cachedOptionValueMethods.get(optionElement);
options.put(optionElement.getOptionName(), new InstanceOptionDescriptor(target, optionElement, optionValueMethod));
}
return CollectionUtils.sort(options.values());
}
示例10: getProjectConfiguration
import org.gradle.util.CollectionUtils; //导入方法依赖的package包/类
public CompositeOperation<Operation> getProjectConfiguration() {
List<Operation> operations = new ArrayList<Operation>();
for (ProjectProfile projectProfile : projects.values()) {
operations.add(projectProfile.getConfigurationOperation());
}
operations = CollectionUtils.sort(operations, Operation.slowestFirst());
return new CompositeOperation<Operation>(operations);
}
示例11: AmbiguousBindingReporter
import org.gradle.util.CollectionUtils; //导入方法依赖的package包/类
public AmbiguousBindingReporter(String referenceType, String referenceDescription, List<Provider> providers) {
this.referenceType = referenceType;
this.referenceDescription = referenceDescription;
this.providers = CollectionUtils.sort(providers, PROVIDER_COMPARATOR);
}
示例12: getSupportedTypes
import org.gradle.util.CollectionUtils; //导入方法依赖的package包/类
public List<String> getSupportedTypes() {
return CollectionUtils.sort(registeredProjectDescriptors.keySet());
}
示例13: getSortedTaskNames
import org.gradle.util.CollectionUtils; //导入方法依赖的package包/类
public List<String> getSortedTaskNames() {
return CollectionUtils.sort(taskNames);
}
示例14: getSortedProjectNames
import org.gradle.util.CollectionUtils; //导入方法依赖的package包/类
public List<String> getSortedProjectNames() {
return CollectionUtils.sort(projectNames);
}
示例15: sortLatestFirst
import org.gradle.util.CollectionUtils; //导入方法依赖的package包/类
private List<ModuleComponentResolveState> sortLatestFirst(Collection<? extends ModuleComponentResolveState> listing) {
return CollectionUtils.sort(listing, Collections.reverseOrder(versionComparator));
}