public static Set<ClassTemplateSpec> directContainedTypes(ClassTemplateSpec spec) { Set<ClassTemplateSpec> results = new HashSet<ClassTemplateSpec>(); for (ClassTemplateSpec nested: directReferencedTypes(spec)) { if (nested.getEnclosingClass() == spec) { results.add(nested); } } return results; }
public static Set<ClassTemplateSpec> allContainedTypes(ClassTemplateSpec spec) { Set<ClassTemplateSpec> results = new HashSet<ClassTemplateSpec>(); for (ClassTemplateSpec nested: allReferencedTypes(spec)) { if (nested.getEnclosingClass() == spec) { results.add(nested); } } return results; }
/** * Currently, one ClassDefinition is provided per .pdsc file. But some of those .pdsc contain * inline schema definitions that should be generated into top level classes. * * This method traverses the spec hierarchy, finding all specs that should be generated as top * level classes. * * I've asked the rest.li team to consider restructuring the generator utilities so that one * ClassDefinition per top level class is provided. If they restructure the utilities, this * method should no longer be needed. */ private static Set<ClassTemplateSpec> findTopLevelTypes(ClassTemplateSpec spec) { Set<ClassTemplateSpec> specs = new HashSet<ClassTemplateSpec>(ClassTemplateSpecs.allReferencedTypes(spec)); specs.add(spec); Iterator<ClassTemplateSpec> iterator = specs.iterator(); while (iterator.hasNext()) { ClassTemplateSpec entry = iterator.next(); if (entry.getEnclosingClass() != null) { iterator.remove(); } } return specs; }