public final class EntitySorter

The EntitySorter is a helper class that allows to sort and validate entities.



public static List<EntityDto> sortByHasARelation(List<EntityDto> allEntities, SchemaHolder schemaHolder)

Takes a list of entities and sorts them, according to relationships they have. The entities that have uni-directional relationship with another entity, will be moved to the position behind the entity they are related with. The bi-directional relationships are not sorted, moreover if invalid bi-directional relationship is found, an exception is thrown.

  • schemaHolder – the holder of the current MDS schema

List of entities, sorted by relationship


public static List<EntityDto> sortByInheritance(List<EntityDto> list)

Takes a list of entities and sorts them by the inheritance tree. The entities that extend the Object class or MdsEntity class will be moved to the beggining of the list. After that, the entites that are already present on the list will be added, up the inheritance tree.

  • list – Initial list of entities to sort

List of entities, sorted by inheritance tree