[RUBY-4423] Rails view: Logical sorting in db​/​migrate folder

This commit is contained in:
Roman Chernyatchik
2009-10-08 19:38:19 +04:00
parent 09ab1dfd8d
commit b0794da4f1
2 changed files with 31 additions and 3 deletions
@@ -165,11 +165,32 @@ public abstract class ProjectViewNode <Value> extends AbstractTreeNode<Value> {
return 0;
}
/**
* When nodes are sorted by type all objects with same weigh will be sorted using
* some common algorithm (e.g alpha comparator). This method allows to perform custom
* sorting for such objects. And default comparison will be applied only if nodes are equal
* from custom comparator's point of view. Also comparison will be applied only if both objects
* have not null comparable keys.
* @return Comparable object.
*/
@Nullable
public Comparable getTypeSortKey() {
return null;
}
/**
* When nodes aren't sorted by type all objects with same weigh will be sorted using
* some common algorithm (e.g alpha comparator). This method allows to perform custom
* sorting for such objects. And default comparison will be applied only if nodes are equal
* from custom comparator's point of view. Also comparison will be applied only if both objects
* have not null comparable keys.
* @return Comparable object.
*/
@Nullable
public Comparable getSortKey() {
return null;
}
@Nullable
public String getQualifiedNameSortKey() {
return null;
@@ -58,10 +58,17 @@ public class GroupByTypeComparator implements Comparator<NodeDescriptor> {
}
if (isSortByType()) {
Comparable typeSortKey1 = node1.getTypeSortKey();
Comparable typeSortKey2 = node2.getTypeSortKey();
final Comparable typeSortKey1 = node1.getTypeSortKey();
final Comparable typeSortKey2 = node2.getTypeSortKey();
if (typeSortKey1 != null && typeSortKey2 != null) {
int result = typeSortKey1.compareTo(typeSortKey2);
final int result = typeSortKey1.compareTo(typeSortKey2);
if (result != 0) return result;
}
} else {
final Comparable typeSortKey1 = node1.getSortKey();
final Comparable typeSortKey2 = node2.getSortKey();
if (typeSortKey1 != null && typeSortKey2 != null) {
final int result = typeSortKey1.compareTo(typeSortKey2);
if (result != 0) return result;
}
}