ca.sqlpower.wabit.dao
Class WabitObjectComparator

java.lang.Object
  extended by ca.sqlpower.wabit.dao.WabitObjectComparator
All Implemented Interfaces:
java.util.Comparator<WabitObject>

public class WabitObjectComparator
extends java.lang.Object
implements java.util.Comparator<WabitObject>

This comparator orders the WabitObjects given based on the following criteria.

  1. Objects are first sorted by their ancestors. The highest ancestor that is different is used to order objects in this case. If the object's immediate parents are the same then the next step is used.
  2. Objects are compared by type. WabitDataSources come before QueryCaches and OlapQueries which come before Layouts. Some objects, like QueryCaches and OlapQueries, are considered to be equivalent in type. If two objects are the same type the next step is used.
  3. Objects are sorted by name. If two objects have the same name then they are sorted by UUID. Object names do not have to be unique but the UUIDs must be unique.
This ordering is used in saving so objects that need to be loaded early should compare to be less than objects that are loaded later.


Constructor Summary
WabitObjectComparator()
           
 
Method Summary
 int compare(WabitObject o1, WabitObject o2)
           
 
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
 

Constructor Detail

WabitObjectComparator

public WabitObjectComparator()
Method Detail

compare

public int compare(WabitObject o1,
                   WabitObject o2)
Specified by:
compare in interface java.util.Comparator<WabitObject>


Copyright © 2009. All Rights Reserved.