* </p>
*/
public List<AttributeType> sort() {
//build a directed graph representing dependencies among types
GraphGenerator gg = new BasicDirectedGraphGenerator();
for (Iterator itr = types.values().iterator(); itr.hasNext();) {
AttributeType type = (AttributeType) itr.next();
AttributeType superType = type.getSuper();
if (superType != null) {
//add edge type -> parent
gg.add(new Object[]{type,superType});
}
if (type instanceof ComplexType) {
ComplexType cType = (ComplexType) type;
//add an edge for each descriptor
Collection atts = cType.getDescriptors();
for (Iterator aitr = atts.iterator(); aitr.hasNext();) {
PropertyDescriptor ad = (PropertyDescriptor) aitr.next();
gg.add(new Object[]{type,ad.getType()});
}
}
}
Graph graph = gg.getGraph();
//test the graph for cycles
CycleDetector cycleDetector = new DirectedCycleDetector(graph);
if (cycleDetector.containsCycle()) {
logger.info("Cycle found");