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

com.slimgears.apt.data.HasParameters Maven / Gradle / Ivy

There is a newer version: 0.7.58
Show newest version
/**
 *
 */
package com.slimgears.apt.data;

import com.google.common.collect.ImmutableList;

import javax.lang.model.element.ExecutableElement;
import java.util.stream.Stream;

public interface HasParameters {
    ImmutableList params();

    @SuppressWarnings("unchecked")
    interface Builder> {
        ImmutableList.Builder paramsBuilder();

        default B addParam(ParamInfo param) {
            paramsBuilder().add(param);
            return (B)this;
        }

        default B addParam(String name, TypeInfo type) {
            return addParam(ParamInfo.create(name, type));
        }

        default B params(Stream params) {
            params.forEach(this::addParam);
            return (B)this;
        }

        default B paramsFromMethod(ExecutableElement executableElement) {
            executableElement.getParameters().forEach(v -> addParam(ParamInfo.of(v)));
            return (B)this;
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy