本文整理汇总了Java中com.google.common.collect.Ordering.from方法的典型用法代码示例。如果您正苦于以下问题:Java Ordering.from方法的具体用法?Java Ordering.from怎么用?Java Ordering.from使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.common.collect.Ordering
的用法示例。
在下文中一共展示了Ordering.from方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeAnnotations
import com.google.common.collect.Ordering; //导入方法依赖的package包/类
public void writeAnnotations(Writer out) throws IOException {
List<MapItem> mapItems = dexFile.getMapItems();
// sort the map items based on the order defined by sectionAnnotationOrder
Ordering<MapItem> ordering = Ordering.from(new Comparator<MapItem>() {
@Override public int compare(MapItem o1, MapItem o2) {
return Ints.compare(sectionAnnotationOrder.get(o1.getType()), sectionAnnotationOrder.get(o2.getType()));
}
});
mapItems = ordering.immutableSortedCopy(mapItems);
try {
for (MapItem mapItem: mapItems) {
SectionAnnotator annotator = annotators.get(mapItem.getType());
annotator.annotateSection(this);
}
} finally {
dexFile.writeAnnotations(out, this);
}
}
示例2: updateSavedBuildTypes
import com.google.common.collect.Ordering; //导入方法依赖的package包/类
private void updateSavedBuildTypes( ) {
final List<BuildTypeData> monitoredBuildTypes = _buildManager.getMonitoredBuildTypes( );
final Ordering<BuildTypeData> ordering = Ordering.from( Comparator.comparingInt( _buildManager::getPosition ) );
final List<SavedBuildTypeData> buildToSaved = ordering.sortedCopy( monitoredBuildTypes ).stream( )
.map( data -> new SavedBuildTypeData( data.getId( ), data.getName( ), data.getProjectId( ), data.getProjectName( ), data.getAliasName( ) ) )
.collect( Collectors.toList( ) );
_configuration.setSavedBuilds( buildToSaved );
}
示例3: updateSavedProjects
import com.google.common.collect.Ordering; //导入方法依赖的package包/类
private void updateSavedProjects( ) {
final List<ProjectData> monitoredProjects = _projectManager.getMonitoredProjects( );
final Ordering<ProjectData> ordering = Ordering.from( Comparator.comparingInt( _projectManager::getPosition ) );
final List<SavedProjectData> projectToSaved = ordering.sortedCopy( monitoredProjects ).stream( )
.map( data -> new SavedProjectData( data.getId( ), data.getName( ), data.getParentId( ).orElse( null ), data.getAliasName( ) ) )
.collect( Collectors.toList( ) );
_configuration.setSavedProjects( projectToSaved );
}
示例4: byPatternsCondition
import com.google.common.collect.Ordering; //导入方法依赖的package包/类
public static Ordering<RequestHandler> byPatternsCondition() {
return Ordering.from(new Comparator<RequestHandler>() {
@Override
public int compare(RequestHandler first, RequestHandler second) {
return first.getRequestMapping().getPatternsCondition().toString()
.compareTo(second.getRequestMapping().getPatternsCondition().toString());
}
});
}