Package org.eclipse.jdt.ui

# Class JavaElementComparator

java.lang.Object
org.eclipse.jface.viewers.ViewerComparator
org.eclipse.jdt.ui.JavaElementComparator

public class JavaElementComparator extends ViewerComparator
Viewer comparator for Java elements. Ordered by element category, then by element name. Package fragment roots are either sorted as ordered on the classpath, or by their name.

This class may be instantiated; it is not intended to be subclassed.

Since:
  3.3
Restriction:
  This class is not intended to be subclassed by clients.

## Constructor Summary

Constructors
Constructor
Description
`JavaElementComparator()`
Constructor.
`JavaElementComparator(boolean sortPFRByName)`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`int`
`category(Object element)`
`int`
`compare(Viewer viewer, Object e1, Object e2)`

### Methods inherited from class org.eclipse.jface.viewers.ViewerComparator

`getComparator, isSorterProperty, sort`

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

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

## Constructor Details

### JavaElementComparator

public JavaElementComparator()
Constructor.

### JavaElementComparator

public JavaElementComparator(boolean sortPFRByName)
Constructor.

Parameters:
  `sortPFRByName` - When `true` `IPackageFragmentRoot`s are sorted by name and not by their classpath order
Since:
  3.14

## Method Details

### category

public int category(Object element)

Overrides:
  `category` in class `ViewerComparator`

### compare

public int compare(Viewer viewer, Object e1, Object e2)

Overrides:
  `compare` in class `ViewerComparator`