/** * Adds the given type declaration to the compilation unit. The list of types will be initialized * if it is <code>null</code>. * * @param cu compilation unit * @param type type declaration */ public static void addTypeDeclaration(CompilationUnit cu, TypeDeclaration type) { List<TypeDeclaration> types = cu.getTypes(); if (types == null) { types = new ArrayList<TypeDeclaration>(); cu.setTypes(types); } types.add(type); }
public CompilationUnitBuilder() { cu = new CompilationUnit(); imports = new HashSet<String>(); cu.setTypes(new ArrayList<TypeDeclaration>()); }