Skip to content

Commit

Permalink
AttributeComparator.
Browse files Browse the repository at this point in the history
  • Loading branch information
LieutenantPeacock committed Dec 27, 2018
1 parent 08d8557 commit 819394b
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/main/java/com/ltpeacock/sorter/xml/AttributeComparator.java
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());
}
}

0 comments on commit 819394b

Please sign in to comment.