de.topicmapslab.majortom.comparator
Class RoleComparator

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

public class RoleComparator
extends java.lang.Object
implements java.util.Comparator<org.tmapi.core.Role>

association role comparator

Author:
Sven Krosse

Field Summary
private  boolean ascending
           
private static RoleComparator instanceAsc
           
private static RoleComparator instanceDesc
           
 
Constructor Summary
private RoleComparator(boolean ascending)
          constructor
 
Method Summary
 int compare(org.tmapi.core.Role o1, org.tmapi.core.Role o2)
          Compare two association items.
static RoleComparator 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 RoleComparator instanceAsc

instanceDesc

private static RoleComparator instanceDesc

ascending

private final boolean ascending
Constructor Detail

RoleComparator

private RoleComparator(boolean ascending)
constructor

Parameters:
ascending - sorting order ascending?
Method Detail

getInstance

public static RoleComparator 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.Role o1,
                   org.tmapi.core.Role o2)
Compare two association items.

Return 0 if both associations roles have the same type and player (lexicographical comparison of identities).

Return -1 if the type or player of the first role is higher (lexicographical comparison of identities).

Return 1 if the type or player of the second role is higher (lexicographical comparison of identities).

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