Пример #1
0
  @Override
  public void handle(ProcessorManager processorManager, RoundEnvironment roundEnvironment) {
    for (BaseContainerHandler containerHandler : handlers) {
      containerHandler.handle(processorManager, roundEnvironment);
    }

    ContentProviderValidator validator = new ContentProviderValidator();
    Collection<ContentProviderDefinition> contentProviderDefinitions = providerMap.values();
    for (ContentProviderDefinition contentProviderDefinition : contentProviderDefinitions) {
      if (validator.validate(processorManager, contentProviderDefinition)) {
        WriterUtils.writeBaseDefinition(contentProviderDefinition, processorManager);
      }
    }
    List<DatabaseWriter> databaseWriters = getManagerWriters();
    for (DatabaseWriter databaseWriter : databaseWriters) {
      try {
        JavaWriter javaWriter =
            new JavaWriter(
                processorManager
                    .getProcessingEnvironment()
                    .getFiler()
                    .createSourceFile(databaseWriter.getSourceFileName())
                    .openWriter());
        databaseWriter.write(javaWriter);
        javaWriter.close();
      } catch (IOException e) {
        processorManager.getMessager().printMessage(Diagnostic.Kind.WARNING, e.getMessage());
      }
    }

    if (roundEnvironment.processingOver()) {
      try {
        JavaWriter staticFlowManager =
            new JavaWriter(
                processorManager
                    .getProcessingEnvironment()
                    .getFiler()
                    .createSourceFile(
                        Classes.FLOW_MANAGER_PACKAGE
                            + "."
                            + Classes.DATABASE_HOLDER_STATIC_CLASS_NAME)
                    .openWriter());
        new FlowManagerHolderWriter(processorManager).write(staticFlowManager);

        staticFlowManager.close();
      } catch (IOException e) {
        processorManager.getMessager().printMessage(Diagnostic.Kind.WARNING, e.getMessage());
      }
    }
  }
Пример #2
0
  private void writeMethod(final String methodName, JavaWriter javaWriter) {
    WriterUtils.emitOverriddenMethod(
        javaWriter,
        new FlowWriter() {
          @Override
          public void write(JavaWriter javaWriter) throws IOException {
            for (OneToManyDefinition oneToManyDefinition : tableDefinition.oneToManyDefinitions) {
              oneToManyDefinition.writeSave(javaWriter);
            }

            javaWriter.emitStatement(
                "super.%1s(%1s)", methodName, ModelUtils.getVariable(isModelContainerAdapter));
          }
        },
        "void",
        methodName,
        Sets.newHashSet(Modifier.PUBLIC, Modifier.FINAL),
        tableDefinition.getModelClassName(),
        ModelUtils.getVariable(isModelContainerAdapter));
  }