EntitySorter

public final class EntitySorter

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

Methods

sortByHasARelation

public static List<Entity> sortByHasARelation(List<Entity> list)

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.

Parameters:
  • list – Initial list of entities to sort
Returns:

List of entities, sorted by relationship

sortByInheritance

public static List<Entity> sortByInheritance(List<Entity> 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.

Parameters:
  • list – Initial list of entities to sort
Returns:

List of entities, sorted by inheritance tree