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

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

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

import com.google.auto.value.AutoValue;

import javax.lang.model.element.VariableElement;

@AutoValue
public abstract class ParamInfo implements HasName, HasType, HasAnnotations {
    public static ParamInfo of(VariableElement element) {
        return builder()
                .name(element.getSimpleName().toString())
                .type(TypeInfo.of(element.asType()).withoutAnnontations())
                .annotationsFromElement(element)
                .build();
    }

    public static Builder builder() {
        return new AutoValue_ParamInfo.Builder();
    }

    public static ParamInfo create(String name, TypeInfo type) {
        return builder().name(name).type(type).build();
    }

    public boolean isOptional() {
        return annotations().stream().anyMatch(a -> a.type().simpleName().equals("Nullable"));
    }

    @AutoValue.Builder
    public interface Builder extends
            InfoBuilder,
            HasName.Builder,
            HasType.Builder,
            HasAnnotations.Builder {
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy