Package org.eclipse.jgit.lib

## Class RefComparator

- java.lang.Object
- - org.eclipse.jgit.lib.RefComparator

All Implemented Interfaces:
  `Comparator<Ref>`

    public class RefComparator
    extends Object
    implements Comparator<Ref>

Util for sorting (or comparing) Ref instances by name.

Useful for command line tools or writing out refs to file.

### Field Summary

Fields
`static RefComparator` `INSTANCE` Singleton instance of RefComparator

### Constructor Summary

Constructors
`RefComparator()`

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`int` `compare​(Ref o1, Ref o2)`
`static int` `compareTo​(Ref o1, String o2)` Compare a reference to a name.
`static int` `compareTo​(Ref o1, Ref o2)` Compare two references by name.
`static Collection<Ref>` `sort​(Collection<Ref> refs)` Sorts the collection of refs, returning a new collection.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface java.util.Comparator

`equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong`

### Field Detail

#### INSTANCE

    public static final RefComparator INSTANCE

Singleton instance of RefComparator

### Constructor Detail

#### RefComparator

    public RefComparator()

### Method Detail

#### compare

    public int compare​(Ref o1,
                       Ref o2)

Specified by:
  `compare` in interface `Comparator<Ref>`

#### sort

    public static Collection<Ref> sort​(Collection<Ref> refs)

Sorts the collection of refs, returning a new collection.

Parameters:
  `refs` - collection to be sorted
Returns:
  sorted collection of refs

#### compareTo

    public static int compareTo​(Ref o1,
                                String o2)

Compare a reference to a name.

Parameters:
  `o1` - the reference instance.
  `o2` - the name to compare to.
Returns:
  standard Comparator result of < 0, 0, > 0.

#### compareTo

    public static int compareTo​(Ref o1,
                                Ref o2)

Compare two references by name.

Parameters:
  `o1` - the reference instance.
  `o2` - the other reference instance.
Returns:
  standard Comparator result of < 0, 0, > 0.