APIdia Launch Partner
Top Description Inners Fields Constructors Methods
jdk.javadoc.internal.doclets.toolkit.util

public Class Comparators

extends Object
Class Inheritance
Imports
com.sun.source.doctree.SerialFieldTree, javax.lang.model.element.Element, .ExecutableElement, .ModuleElement, .PackageElement, .TypeElement, .TypeParameterElement, .VariableElement, javax.lang.model.type.ArrayType, .PrimitiveType, .TypeMirror, javax.lang.model.util.SimpleElementVisitor14, .SimpleTypeVisitor9, java.util.Arrays, .Comparator, .List

A collection of Comparator factory methods.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private abstract class
Comparators.ElementComparator

A general purpose comparator to sort Element entities, basically provides the building blocks for creating specific comparators for each use-case.

Field Summary

Modifier and TypeField and Description
private Comparator<Element>
private Comparator<Element>
private Comparator<Element>
private Comparator<Element>
private Comparator<Element>
private Comparator<Element>
private Comparator<SerialFieldTree>
private Comparator<Element>
private Comparator<TypeMirror>
private Comparator<TypeMirror>
private final Utils

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public Comparator<Element>

Returns:

the comparator
allClassesComparator
()

Returns a comparator for all classes, that compares the simple names of the type element, if equal then the fully qualified names, and if equal again the names of the enclosing modules.

public Comparator<Element>

Returns:

a comparator to sort classes and members for class use
classUseComparator
()

Comparator for ClassUse presentations, and sorts as follows: 1.

public Comparator<Element>

Returns:

the comparator
generalPurposeComparator
()

Returns a general purpose comparator.

public Comparator<Element>

Returns:

an element comparator for index file use
indexElementComparator
()

Returns an Element Comparator for index file presentations, and are sorted as follows.

public String

Returns:

the element's primary key for use in the index comparator
indexElementKey
(Element
an element
element
)

Returns the element's primary key for use in the index comparator.

public Comparator<Element>

Returns:

the comparator
moduleComparator
()

Returns a comparator for module elements, that simply compares the fully qualified names

public Comparator<Element>

Returns:

the comparator
overrideUseComparator
()

Returns a comparator for overrides and implements, used primarily on methods, compares the name first, then compares the simple names of the enclosing type element and the fully qualified name of the enclosing type element.

public Comparator<Element>

Returns:

the comparator
packageComparator
()

Returns a comparator for packages, by comparing the fully qualified names, and if those are equal the names of the enclosing modules.

public Comparator<SerialFieldTree>

Returns:

the comparator
serialFieldTreeComparator
()

Returns a comparator for SerialFieldTrees.

public Comparator<Element>

Returns:

the comparator
summaryComparator
()

Returns a comparator for items listed on summary list pages (like deprecated or preview summary pages), by comparing the fully qualified names, and if those are equal the names of the enclosing modules.

public Comparator<TypeMirror>

Returns:

the comparator
typeMirrorClassUseComparator
()

Returns a comparator that compares the fully qualified names of two type mirrors.

public Comparator<TypeMirror>

Returns:

the comparator
typeMirrorIndexUseComparator
()

Returns a comparator that compares the simple names of two type mirrors, or the fully qualified names if the simple names are equal.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

allClassesComparatorback to summary
private Comparator<Element> allClassesComparator
classUseComparatorback to summary
private Comparator<Element> classUseComparator
indexUseComparatorback to summary
private Comparator<Element> indexUseComparator
moduleComparatorback to summary
private Comparator<Element> moduleComparator
overrideUseComparatorback to summary
private Comparator<Element> overrideUseComparator
packageComparatorback to summary
private Comparator<Element> packageComparator
serialFieldTreeComparatorback to summary
private Comparator<SerialFieldTree> serialFieldTreeComparator
summaryComparatorback to summary
private Comparator<Element> summaryComparator
typeMirrorClassUseComparatorback to summary
private Comparator<TypeMirror> typeMirrorClassUseComparator
typeMirrorIndexUseComparatorback to summary
private Comparator<TypeMirror> typeMirrorIndexUseComparator
utilsback to summary
private final Utils utils

Constructor Detail

Comparatorsback to summary
pack-priv Comparators(Utils utils)

Method Detail

allClassesComparatorback to summary
public Comparator<Element> allClassesComparator()

Returns a comparator for all classes, that compares the simple names of the type element, if equal then the fully qualified names, and if equal again the names of the enclosing modules.

Returns:Comparator<Element>

the comparator

classUseComparatorback to summary
public Comparator<Element> classUseComparator()

Comparator for ClassUse presentations, and sorts as follows: 1. member names 2. then fully qualified member names 3. then parameter types if applicable 4. the element kinds ie. package, class, interface etc. 5. finally the name of the enclosing modules

Returns:Comparator<Element>

a comparator to sort classes and members for class use

generalPurposeComparatorback to summary
public Comparator<Element> generalPurposeComparator()

Returns a general purpose comparator.

Returns:Comparator<Element>

the comparator

indexElementComparatorback to summary
public Comparator<Element> indexElementComparator()

Returns an Element Comparator for index file presentations, and are sorted as follows. If comparing modules and/or packages then simply compare the qualified names, if comparing a module or a package with a type/member then compare the FullyQualifiedName of the module or a package with the SimpleName of the entity, otherwise: 1. compare the ElementKind ex: Module, Package, Interface etc. 2a. if equal and if the type is of ExecutableElement(Constructor, Methods), a case-insensitive comparison of parameter the type signatures 2b. if equal, case-sensitive comparison of the type signatures 3. if equal, compare the FQNs of the entities 4. finally, if equal, compare the names of the enclosing modules

Returns:Comparator<Element>

an element comparator for index file use

indexElementKeyback to summary
public String indexElementKey(Element element)

Returns the element's primary key for use in the index comparator. This method can be used by other comparators which need to produce results that are consistent with the index comparator.

Parameters
element:Element

an element

Returns:String

the element's primary key for use in the index comparator

moduleComparatorback to summary
public Comparator<Element> moduleComparator()

Returns a comparator for module elements, that simply compares the fully qualified names

Returns:Comparator<Element>

the comparator

overrideUseComparatorback to summary
public Comparator<Element> overrideUseComparator()

Returns a comparator for overrides and implements, used primarily on methods, compares the name first, then compares the simple names of the enclosing type element and the fully qualified name of the enclosing type element.

Returns:Comparator<Element>

the comparator

packageComparatorback to summary
public Comparator<Element> packageComparator()

Returns a comparator for packages, by comparing the fully qualified names, and if those are equal the names of the enclosing modules.

Returns:Comparator<Element>

the comparator

serialFieldTreeComparatorback to summary
public Comparator<SerialFieldTree> serialFieldTreeComparator()

Returns a comparator for SerialFieldTrees.

Returns:Comparator<SerialFieldTree>

the comparator

summaryComparatorback to summary
public Comparator<Element> summaryComparator()

Returns a comparator for items listed on summary list pages (like deprecated or preview summary pages), by comparing the fully qualified names, and if those are equal the names of the enclosing modules.

Returns:Comparator<Element>

the comparator

typeMirrorClassUseComparatorback to summary
public Comparator<TypeMirror> typeMirrorClassUseComparator()

Returns a comparator that compares the fully qualified names of two type mirrors.

Returns:Comparator<TypeMirror>

the comparator

typeMirrorIndexUseComparatorback to summary
public Comparator<TypeMirror> typeMirrorIndexUseComparator()

Returns a comparator that compares the simple names of two type mirrors, or the fully qualified names if the simple names are equal.

Returns:Comparator<TypeMirror>

the comparator

jdk.javadoc.internal.doclets.toolkit.util back to summary

private abstract Class Comparators.ElementComparator

extends Object
implements Comparator<Element>
Class Inheritance
  • java.lang.Object
  • jdk.javadoc.internal.doclets.toolkit.util.Comparators.ElementComparator
All Implemented Interfaces
java.util.Comparator

A general purpose comparator to sort Element entities, basically provides the building blocks for creating specific comparators for each use-case.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected int

Returns:

a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second
compareElementKinds
(Element
the first element
e1
,
Element
the second element
e2
)

Compares the kinds of two elements.

protected int

Returns:

a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.
compareFullyQualifiedNames
(Element
the first Element.
e1
,
Element
the first Element.
e2
)

Compares the fully qualified names of the entities

protected int

Returns:

a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second
compareModuleNames
(Element
the first element
e1
,
Element
the second element
e2
)

Compares the name of the modules of two elements.

protected int

Returns:

a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.
compareNames
(Element
the first Element.
e1
,
Element
the second Element.
e2
)

Compares two Elements, typically the name of a method, field or constructor.

protected int

Returns:

a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.
compareParameters
(boolean caseSensitive, List<? extends VariableElement>
the first parameter array.
params1
,
List<? extends VariableElement>
the first parameter array.
params2
)

compares two parameter arrays by first comparing the length of the arrays, and then each Type of the parameter in the array.

protected int

Returns:

a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second
compareParameters
(Element
the first element
e1
,
Element
the second element
e2
)

Compares the parameter arrays of two elements if they both are executable.

protected final int
private String

Returns:

a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.
getFullyQualifiedName
(Element e)

The fully qualified names of the entities, used solely by the comparator.

private int
pack-priv String
private String
pack-priv boolean
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

ElementComparatorback to summary
public ElementComparator()

Method Detail

compareElementKindsback to summary
protected int compareElementKinds(Element e1, Element e2)

Compares the kinds of two elements.

Parameters
e1:Element

the first element

e2:Element

the second element

Returns:int

a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second

compareFullyQualifiedNamesback to summary
protected int compareFullyQualifiedNames(Element e1, Element e2)

Compares the fully qualified names of the entities

Parameters
e1:Element

the first Element.

e2:Element

the first Element.

Returns:int

a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.

compareModuleNamesback to summary
protected int compareModuleNames(Element e1, Element e2)

Compares the name of the modules of two elements.

Parameters
e1:Element

the first element

e2:Element

the second element

Returns:int

a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second

compareNamesback to summary
protected int compareNames(Element e1, Element e2)

Compares two Elements, typically the name of a method, field or constructor.

Parameters
e1:Element

the first Element.

e2:Element

the second Element.

Returns:int

a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.

compareParametersback to summary
protected int compareParameters(boolean caseSensitive, List<? extends VariableElement> params1, List<? extends VariableElement> params2)

compares two parameter arrays by first comparing the length of the arrays, and then each Type of the parameter in the array.

Parameters
params1:List<? extends VariableElement>

the first parameter array.

params2:List<? extends VariableElement>

the first parameter array.

Returns:int

a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.

compareParametersback to summary
protected int compareParameters(Element e1, Element e2)

Compares the parameter arrays of two elements if they both are executable.

Parameters
e1:Element

the first element

e2:Element

the second element

Returns:int

a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second

compareTypeParametersback to summary
protected final int compareTypeParameters(Element e1, Element e2)
getFullyQualifiedNameback to summary
private String getFullyQualifiedName(Element e)

The fully qualified names of the entities, used solely by the comparator.

Returns:String

a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.

getKindIndexback to summary
private int getKindIndex(Element e)
getParametersAsStringback to summary
pack-priv String getParametersAsString(List<? extends VariableElement> params)
getTypeCodeback to summary
private String getTypeCode(TypeMirror t)
hasParametersback to summary
pack-priv boolean hasParameters(Element e)