com.slimgears.apt.data.ParamInfo Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of apt-utils Show documentation
Show all versions of apt-utils Show documentation
General purpose utils / module: apt-utils
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