private Set collectTypesUsedByTypes()

in src/main/java/org/apache/uima/json/jsoncas2/ser/TypeSystemSerializer.java [101:133]


  private Set<Type> collectTypesUsedByTypes(TypeSystem aTypeSystem, Iterable<Type> typesSource, Deque<Type> queue) {
    Set<Type> typeSet = new HashSet<>();
    while (!queue.isEmpty()) {
      Type t = queue.poll();

      if (typeSet.contains(t)) {
        continue;
      }

      for (Feature f : t.getFeatures()) {
        Type parent = aTypeSystem.getParent(t);
        while (parent != null) {
          if (!typeSet.contains(parent)) {
            queue.add(parent);
          }
          parent = aTypeSystem.getParent(parent);
        }
        
        Type range = f.getRange();
        if (!typeSet.contains(range)) {
          queue.add(range);
        }
        
        Type componentType = range.getComponentType();
        if (componentType != null && !typeSet.contains(typesSource)) {
          queue.add(componentType);
        }
      }
      
      typeSet.add(t);
    }
    return typeSet;
  }