-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
08d8557
commit 819394b
Showing
1 changed file
with
24 additions
and
0 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
src/main/java/com/ltpeacock/sorter/xml/AttributeComparator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.ltpeacock.sorter.xml; | ||
|
||
import java.util.Comparator; | ||
|
||
import org.w3c.dom.Node; | ||
|
||
/** | ||
* Comparator for sorting attributes lexicographically by attribute name. | ||
* <br> | ||
* Attributes are represented by the class {@link org.w3c.dom.Node}. | ||
* @author LieutenantPeacock | ||
* | ||
*/ | ||
public class AttributeComparator implements Comparator<Node> { | ||
/** | ||
* Comparator for maintaining original order of attributes on elements. | ||
*/ | ||
public static final Comparator<Node> MAINTAIN_ORDER = (a,b) -> 0; | ||
|
||
@Override | ||
public int compare(final Node o1, final Node o2) { | ||
return Util.compare(o1.getNodeName(), o2.getNodeName()); | ||
} | ||
} |