aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit/src/org/eclipse/jgit/lib/RefComparator.java
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.jgit/src/org/eclipse/jgit/lib/RefComparator.java')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/lib/RefComparator.java32
1 files changed, 29 insertions, 3 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/RefComparator.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/RefComparator.java
index fe6d210c11..f14488b73e 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/RefComparator.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/RefComparator.java
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2008, Charles O'Farrell <charleso@charleso.org>
- * Copyright (C) 2008, Google Inc.
+ * Copyright (C) 2010, Google Inc.
* and other copyright owners as documented in the project's IP log.
*
* This program and the accompanying materials are made available
@@ -61,12 +61,12 @@ public class RefComparator implements Comparator<Ref> {
public static final RefComparator INSTANCE = new RefComparator();
public int compare(final Ref o1, final Ref o2) {
- return o1.getOrigName().compareTo(o2.getOrigName());
+ return compareTo(o1, o2);
}
/**
* Sorts the collection of refs, returning a new collection.
- *
+ *
* @param refs
* collection to be sorted
* @return sorted collection of refs
@@ -76,4 +76,30 @@ public class RefComparator implements Comparator<Ref> {
Collections.sort(r, INSTANCE);
return r;
}
+
+ /**
+ * Compare a reference to a name.
+ *
+ * @param o1
+ * the reference instance.
+ * @param o2
+ * the name to compare to.
+ * @return standard Comparator result of < 0, 0, > 0.
+ */
+ public static int compareTo(Ref o1, String o2) {
+ return o1.getName().compareTo(o2);
+ }
+
+ /**
+ * Compare two references by name.
+ *
+ * @param o1
+ * the reference instance.
+ * @param o2
+ * the other reference instance.
+ * @return standard Comparator result of < 0, 0, > 0.
+ */
+ public static int compareTo(final Ref o1, final Ref o2) {
+ return o1.getName().compareTo(o2.getName());
+ }
}