@Test public void testSortObjectClassesShuffled() { List<String> oids = Arrays.asList( "1.1.1", "1.1.2", "1.1.3", "1.1.4", "1.1.5", "1.1.6" ); for ( int i = 0; i < 1000; i++ ) { Collections.shuffle( oids ); Iterator<String> oidIterator = oids.iterator(); List<ObjectClass> objectClasses = new ArrayList<ObjectClass>(); addObjectClass( objectClasses, oidIterator.next(), "oc1" ); addObjectClass( objectClasses, oidIterator.next(), "OC2", "oc1" ); addObjectClass( objectClasses, oidIterator.next(), "oc3", "Oc2" ); addObjectClass( objectClasses, oidIterator.next(), "oc4" ); addObjectClass( objectClasses, oidIterator.next(), "oc5", "oC2", "OC4" ); addObjectClass( objectClasses, oidIterator.next(), "oc6", "other" ); Iterable<ObjectClass> sorted = SchemaObjectSorter.sortObjectClasses( objectClasses ); assertHierarchicalOrderOC( sorted ); } }
public static Iterable<ObjectClass> sortObjectClasses( List<ObjectClass> objectClasses ) { return new SchemaObjectIterable<>( objectClasses, new ReferenceCallback<ObjectClass>() { @Override public Collection<String> getSuperiorOids( ObjectClass oc ) { return oc.getSuperiorOids(); } } ); }
SchemaObjectSorter { public static Iterable<ObjectClass> sortObjectClasses( List<ObjectClass> objectClasses ) { return new SchemaObjectIterable<>( objectClasses, new ReferenceCallback<ObjectClass>() { @Override public Collection<String> getSuperiorOids( ObjectClass oc ) { return oc.getSuperiorOids(); } } ); } }
SchemaObjectSorter { public static Iterable<ObjectClass> sortObjectClasses( List<ObjectClass> objectClasses ) { return new SchemaObjectIterable<>( objectClasses, new ReferenceCallback<ObjectClass>() { @Override public Collection<String> getSuperiorOids( ObjectClass oc ) { return oc.getSuperiorOids(); } } ); } private  SchemaObjectSorter(); }
SchemaObjectSorter { public static Iterable<ObjectClass> sortObjectClasses( List<ObjectClass> objectClasses ) { return new SchemaObjectIterable<>( objectClasses, new ReferenceCallback<ObjectClass>() { @Override public Collection<String> getSuperiorOids( ObjectClass oc ) { return oc.getSuperiorOids(); } } ); } private  SchemaObjectSorter(); static Iterable<AttributeType> hierarchicalOrdered( List<AttributeType> attributeTypes ); static Iterable<ObjectClass> sortObjectClasses( List<ObjectClass> objectClasses ); }
SchemaObjectSorter { public static Iterable<ObjectClass> sortObjectClasses( List<ObjectClass> objectClasses ) { return new SchemaObjectIterable<>( objectClasses, new ReferenceCallback<ObjectClass>() { @Override public Collection<String> getSuperiorOids( ObjectClass oc ) { return oc.getSuperiorOids(); } } ); } private  SchemaObjectSorter(); static Iterable<AttributeType> hierarchicalOrdered( List<AttributeType> attributeTypes ); static Iterable<ObjectClass> sortObjectClasses( List<ObjectClass> objectClasses );  }