de.topicmapslab.majortom.comparator
Class ConstructByItemIdentifierComparator<T extends org.tmapi.core.Construct>

java.lang.Object
  extended by de.topicmapslab.majortom.comparator.ConstructByItemIdentifierComparator<T>
All Implemented Interfaces:
java.util.Comparator<T>

public class ConstructByItemIdentifierComparator<T extends org.tmapi.core.Construct>
extends java.lang.Object
implements java.util.Comparator<T>

Special comparator ordering constructs by their item-identifier

Author:
Sven Krosse

Field Summary
private  boolean ascending
           
 
Constructor Summary
ConstructByItemIdentifierComparator()
          constructor Sorting order is ascending.
ConstructByItemIdentifierComparator(boolean ascending)
          constructor
 
Method Summary
 int compare(T o1, T o2)
          Compare two constructs of the specified type.
 
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
 

Field Detail

ascending

private final boolean ascending
Constructor Detail

ConstructByItemIdentifierComparator

public ConstructByItemIdentifierComparator()
constructor Sorting order is ascending.


ConstructByItemIdentifierComparator

public ConstructByItemIdentifierComparator(boolean ascending)
constructor

Parameters:
ascending - sorting order ascending?
Method Detail

compare

public int compare(T o1,
                   T o2)
Compare two constructs of the specified type.

Return 0 if both constructs has no item-identifiers.

Return -1 if only the first construct has no item-identifiers or the reference of the first item-identifier is lexicographically smaller.

Return -1 if only the second construct has no item-identifiers or the reference of the second item-identifier is lexicographically higher.

Specified by:
compare in interface java.util.Comparator<T extends org.tmapi.core.Construct>