All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.smallrye.mutiny.vertx.codegen.lang.ConsumerMethodCodeWriter Maven / Gradle / Ivy

The newest version!
package io.smallrye.mutiny.vertx.codegen.lang;

import io.vertx.codegen.ClassModel;

import java.io.PrintWriter;

/**
 * If the class implements {@code Handler}, we added {@code Consumer} and so we need to implement that method.
 */
public class ConsumerMethodCodeWriter implements ConditionalCodeWriter {
    @Override
    public void generate(ClassModel model, PrintWriter writer) {
        if (model.isConcrete()) {
            writer.println("  public void accept(" + genTypeName(model.getHandlerArg()) + " item) {");
            writer.println("    handle(item);");
            writer.println("  }");
        } else {
            writer.println("  default public void accept(" + genTypeName(model.getHandlerArg()) + " item) {");
            writer.println("    handle(item);");
            writer.println("  }");
        }
    }

    @Override
    public boolean test(ClassModel classModel) {
        return classModel.isHandler();
    }


}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy