de.topicmapslab.majortom.comparator
Class ScopeComparator

java.lang.Object
  extended by de.topicmapslab.majortom.comparator.ScopeComparator
All Implemented Interfaces:
java.util.Comparator<de.topicmapslab.majortom.model.core.IScope>

public class ScopeComparator
extends java.lang.Object
implements java.util.Comparator<de.topicmapslab.majortom.model.core.IScope>

scope comparator

Since:
1.1.2
Author:
Sven Krosse

Field Summary
private  boolean ascending
           
private static ScopeComparator instanceAsc
           
private static ScopeComparator instanceDesc
           
 
Constructor Summary
private ScopeComparator(boolean ascending)
          constructor
 
Method Summary
 int compare(de.topicmapslab.majortom.model.core.IScope o1, de.topicmapslab.majortom.model.core.IScope o2)
          Compare two scope items.
static ScopeComparator 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 ScopeComparator instanceAsc

instanceDesc

private static ScopeComparator instanceDesc

ascending

private final boolean ascending
Constructor Detail

ScopeComparator

private ScopeComparator(boolean ascending)
constructor

Parameters:
ascending - sorting order ascending?
Method Detail

getInstance

public static ScopeComparator 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(de.topicmapslab.majortom.model.core.IScope o1,
                   de.topicmapslab.majortom.model.core.IScope o2)
Compare two scope items.

Return 0 if both scopes has the same number of themes.

Return -1 if the number of themes of the first scope is smaller than of the second scope.

Return 1 if the number of themes of the first scope is higher than of the second scope.

Specified by:
compare in interface java.util.Comparator<de.topicmapslab.majortom.model.core.IScope>