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

net.jbock.annotated.AnnotatedParameters 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.SnakeName;

import java.util.Locale;
import java.util.stream.Stream;

public final class AnnotatedParameters extends AnnotatedMethod {

    private final ExecutableParameters parameters;

    private AnnotatedParameters(
            EnumName enumName,
            ExecutableParameters parameters,
            String paramLabel) {
        super(enumName, paramLabel);
        this.parameters = parameters;
    }

    static AnnotatedParameters createParameters(
            ExecutableParameters parameters,
            EnumName enumName) {
        String paramLabel = parameters.paramLabel()
                .orElseGet(() -> SnakeName.create(parameters.simpleName().toString())
                        .snake('_')
                        .toUpperCase(Locale.US));
        return new AnnotatedParameters(enumName, parameters, paramLabel);
    }

    @Override
    Executable executable() {
        return parameters;
    }

    @Override
    public boolean isParameter() {
        return false;
    }

    @Override
    public boolean isParameters() {
        return true;
    }

    @Override
    Stream asAnnotatedOption() {
        return Stream.empty();
    }

    @Override
    Stream asAnnotatedParameter() {
        return Stream.empty();
    }

    @Override
    Stream asAnnotatedParameters() {
        return Stream.of(this);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy