code: 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);
  
      }
docs: 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