code: private static Consumer<JavaFile> write(ProcessingEnvironment processingEnv) {
          return file -> {
              try {
                  file.writeTo(processingEnv.getFiler());
              } catch (IOException e) {
                  JavaFileObject obj = file.toJavaFileObject();
                  throw new ProcessingException("Can't write", obj.getName(), obj.getKind(), e);
              }
          };
      }
docs: Consumer which writes classes as java files