de.topicmapslab.majortom.comparator
Class AssociationComparator

java.lang.Object
  extended by de.topicmapslab.majortom.comparator.AssociationComparator
All Implemented Interfaces:
java.util.Comparator<org.tmapi.core.Association>

public class AssociationComparator
extends java.lang.Object
implements java.util.Comparator<org.tmapi.core.Association>

association comparator

Author:
Sven Krosse

Field Summary
private  boolean ascending
           
private static AssociationComparator instanceAsc
           
private static AssociationComparator instanceDesc
           
 
Constructor Summary
private AssociationComparator(boolean ascending)
          constructor
 
Method Summary
 int compare(org.tmapi.core.Association o1, org.tmapi.core.Association o2)
          Compare two association items.
static AssociationComparator getInstance(boolean ascending)
          Returns the singleton instance of the comparator
 
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

instanceAsc

private static AssociationComparator instanceAsc

instanceDesc

private static AssociationComparator instanceDesc

ascending

private final boolean ascending
Constructor Detail

AssociationComparator

private AssociationComparator(boolean ascending)
constructor

Parameters:
ascending - sorting order ascending?
Method Detail

getInstance

public static AssociationComparator getInstance(boolean ascending)
Returns the singleton instance of the comparator

Parameters:
ascending - sorting order ascending?
Returns:
the instance the comparator instance

compare

public int compare(org.tmapi.core.Association o1,
                   org.tmapi.core.Association o2)
Compare two association items.

Return 0 if both associations have the same type and number of roles.

Return -1 if the identity of the first type is higher or the second association has more roles

Return 1 if the identity of the second type is higher or the first association has more roles

Specified by:
compare in interface java.util.Comparator<org.tmapi.core.Association>