Java Code Examples for org.mybatis.generator.api.dom.java.Method#isAbstract()

The following examples show how to use org.mybatis.generator.api.dom.java.Method#isAbstract() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MethodRenderer.java    From mapper-generator-javafx with Apache License 2.0 5 votes vote down vote up
public List<String> render(Method method, boolean inInterface, CompilationUnit compilationUnit) {
    List<String> lines = new ArrayList<>();

    lines.addAll(method.getJavaDocLines());
    lines.addAll(method.getAnnotations());
    lines.add(getFirstLine(method, inInterface, compilationUnit));
    
    if (!method.isAbstract() && !method.isNative()) {
        lines.addAll(bodyLineRenderer.render(method.getBodyLines()));
        lines.add("}");
    }

    return lines;
}
 
Example 2
Source File: MethodRenderer.java    From mapper-generator-javafx with Apache License 2.0 4 votes vote down vote up
private String getFirstLine(Method method, boolean inInterface, CompilationUnit compilationUnit) {
    StringBuilder sb = new StringBuilder();

    sb.append(renderVisibility(method, inInterface));

    if (method.isAbstract() && !inInterface) {
        sb.append("abstract ");
    }

    if (method.isDefault()) {
        sb.append("default ");
    }

    if (method.isStatic()) {
        sb.append("static ");
    }

    if (method.isFinal()) {
        sb.append("final ");
    }

    if (method.isSynchronized()) {
        sb.append("synchronized ");
    }

    if (method.isNative()) {
        sb.append("native ");
    }

    sb.append(renderTypeParameters(method, compilationUnit));
    
    if (!method.isConstructor()) {
        sb.append(method.getReturnType()
                .map(t -> JavaDomUtils.calculateTypeName(compilationUnit, t))
                .orElse("void"));
        
        sb.append(' ');
    }

    sb.append(method.getName());
    
    sb.append(renderParameters(method, compilationUnit));
    
    sb.append(renderExceptions(method, compilationUnit));
    
    if (method.isAbstract() || method.isNative()) {
        sb.append(';');
    } else {
        sb.append(" {");
    }
    return sb.toString();

}