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

net.jbock.annotated.AnnotatedMethod Maven / Gradle / Ivy

There is a newer version: 5.18
Show newest version
package net.jbock.annotated;

import net.jbock.common.EnumName;
import net.jbock.common.ValidationFailure;

import javax.lang.model.element.ExecutableElement;
import javax.lang.model.element.Modifier;
import javax.lang.model.element.TypeElement;
import javax.lang.model.type.TypeMirror;
import java.util.List;
import java.util.Optional;
import java.util.stream.Stream;

public abstract class AnnotatedMethod {

    private final EnumName enumName;
    private final String paramLabel;

    AnnotatedMethod(
            EnumName enumName,
            String paramLabel) {
        this.enumName = enumName;
        this.paramLabel = paramLabel;
    }

    abstract Executable executable();

    public abstract boolean isParameter();

    public abstract boolean isParameters();

    abstract Stream asAnnotatedOption();

    abstract Stream asAnnotatedParameter();

    abstract Stream asAnnotatedParameters();

    public final EnumName enumName() {
        return enumName;
    }

    public final String methodName() {
        return method().getSimpleName().toString();
    }

    public final TypeMirror returnType() {
        return method().getReturnType();
    }

    public final String paramLabel() {
        return paramLabel;
    }

    public final List accessModifiers() {
        return executable().accessModifiers();
    }

    public final Optional converter() {
        return executable().converter();
    }

    public final ValidationFailure fail(String message) {
        return executable().fail(message);
    }

    public final ExecutableElement method() {
        return executable().method();
    }

    public final Optional descriptionKey() {
        return executable().descriptionKey();
    }

    public final List description() {
        return executable().description();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy