code: public List<EntityType> resolve(Collection<EntityType> entityTypes) {
      if (entityTypes.isEmpty()) {
        return emptyList();
      }
      if (entityTypes.size() == 1) {
        return singletonList(entityTypes.iterator().next());
      }
  
      // EntityType doesn't have equals/hashcode methods, map to nodes first
      // ensure that nodes exist for all dependencies
      Set<EntityTypeNode> entityTypeNodes =
          entityTypes
              .stream()
              .map(EntityTypeNode::new)
              .flatMap(
                  node -> Stream.concat(Stream.of(node), expandEntityTypeDependencies(node).stream()))
              .collect(toCollection(HashSet::new));
  
      // Sort nodes based on dependencies
      List<EntityTypeNode> resolvedEntityMetaNodes =
          genericDependencyResolver.resolve(entityTypeNodes, getDependencies());
      // Map nodes back to EntityType
      List<EntityType> resolvedEntityMetas =
          resolvedEntityMetaNodes.stream().map(EntityTypeNode::getEntityType).collect(toList());
  
      // getDependencies might have included items that are not in the input list, remove additional
      // items
      if (resolvedEntityMetas.size() == entityTypes.size()) {
        return resolvedEntityMetas;
      } else {
        Map<String, EntityType> entityTypeMap =
            entityTypes.stream().collect(toMap(EntityType::getId, Function.identity()));
        return resolvedEntityMetas
            .stream()
            .filter(resolvedEntityMeta -> entityTypeMap.containsKey(resolvedEntityMeta.getId()))
            .collect(toList());
      }
    }
docs: Sort {@link EntityType} collection based on their dependencies.
  
  @param entityTypes entity meta data collection
  @return sorted entity meta data collection based on dependencies