Class BuilderTypeTools
java.lang.Object
io.helidon.builder.processor.tools.BuilderTypeTools
- All Implemented Interfaces:
TypeInfoCreatorProvider
The default implementation for
TypeInfoCreatorProvider. This also contains an abundance of
other useful methods used for annotation processing.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleancanAccept(ExecutableElement ee, boolean defineDefaultMethods) Returns true if the executable element passed is acceptable for processing.static StringcopyrightHeaderFor(String generatorClassTypeName) Produces the generated copy right header on code generated artifacts.static Optional<AnnotationAndValue>createAnnotationAndValueFromMirror(AnnotationMirror am, Elements elements) Creates an instance from an annotation mirror during annotation processing.static List<AnnotationAndValue>createAnnotationAndValueListFromElement(Element e, Elements elements) Creates an instance from a variable element during annotation processing.static TypedElementNamecreateTypedElementNameFromElement(Element v, Elements elements) Creates an instance of aTypedElementNamegiven its type and variable element from annotation processing.createTypeInfo(TypeName annotationTypeName, TypeName typeName, TypeElement element, ProcessingEnvironment processingEnv, boolean wantDefaultMethods) static Optional<DefaultTypeName>Creates a name from a declared type during annotation processing.static Optional<DefaultTypeName>Creates a name from an element type during annotation processing.static Optional<DefaultTypeName>createTypeNameFromMirror(TypeMirror typeMirror) Converts a type mirror to a type name during annotation processing.static StringextractValue(AnnotationMirror am, Elements elements) Extracts the singularvalue()value.extractValues(Map<? extends ExecutableElement, ? extends AnnotationValue> values) Extracts values from the annotation element values.extractValues(AnnotationMirror am, Elements elements) Extracts values from the annotation mirror value.static Optional<? extends AnnotationMirror>findAnnotationMirror(String annotationType, Collection<? extends AnnotationMirror> ams) Locate an annotation mirror by name.static StringgeneratedStickerFor(String generatorClassTypeName, String versionId) Produces the generated sticker annotation attribute contents.protected Collection<TypedElementName>toElementInfo(TypeElement element, ProcessingEnvironment processingEnv, boolean wantWhatWeCanAccept, boolean wantDefaultMethods) Translation the arguments to a collection ofTypedElementName's.static Optional<TypeElement>toTypeElement(TypeMirror typeMirror) Translates aTypeMirrorinto aTypeElement.
-
Constructor Details
-
BuilderTypeTools
Deprecated.needed for service loaderDefault constructor. Service loaded.
-
-
Method Details
-
createTypeInfo
public Optional<TypeInfo> createTypeInfo(TypeName annotationTypeName, TypeName typeName, TypeElement element, ProcessingEnvironment processingEnv, boolean wantDefaultMethods) - Specified by:
createTypeInfoin interfaceTypeInfoCreatorProvider
-
toElementInfo
protected Collection<TypedElementName> toElementInfo(TypeElement element, ProcessingEnvironment processingEnv, boolean wantWhatWeCanAccept, boolean wantDefaultMethods) Translation the arguments to a collection ofTypedElementName's.- Parameters:
element- the typed element (i.e., class)processingEnv- the processing envwantWhatWeCanAccept- pass true to get the elements we can accept to process, false for the other oneswantDefaultMethods- true to processdefaultmethods- Returns:
- the collection of typed elements
-
canAccept
Returns true if the executable element passed is acceptable for processing. By default that means methods that are not static or default methods.- Parameters:
ee- the executable elementdefineDefaultMethods- true if we should also process default methods- Returns:
- true if not able to accept
-
toTypeElement
Translates aTypeMirrorinto aTypeElement.- Parameters:
typeMirror- the type mirror- Returns:
- the type element
-
createTypeNameFromDeclaredType
Creates a name from a declared type during annotation processing.- Parameters:
type- the element type- Returns:
- the associated type name instance
-
createTypeNameFromElement
Creates a name from an element type during annotation processing.- Parameters:
type- the element type- Returns:
- the associated type name instance
-
createTypeNameFromMirror
Converts a type mirror to a type name during annotation processing.- Parameters:
typeMirror- the type mirror- Returns:
- the type name associated with the type mirror, or empty for generic type variables
-
findAnnotationMirror
public static Optional<? extends AnnotationMirror> findAnnotationMirror(String annotationType, Collection<? extends AnnotationMirror> ams) Locate an annotation mirror by name.- Parameters:
annotationType- the annotation type to search forams- the collection to search through- Returns:
- the annotation mirror, or empty if not found
-
createAnnotationAndValueFromMirror
public static Optional<AnnotationAndValue> createAnnotationAndValueFromMirror(AnnotationMirror am, Elements elements) Creates an instance from an annotation mirror during annotation processing.- Parameters:
am- the annotation mirrorelements- the elements- Returns:
- the new instance or empty if the annotation mirror passed is invalid
-
createAnnotationAndValueListFromElement
public static List<AnnotationAndValue> createAnnotationAndValueListFromElement(Element e, Elements elements) Creates an instance from a variable element during annotation processing.- Parameters:
e- the variable/type elementelements- the elements- Returns:
- the list of annotations extracted from the element
-
extractValues
Extracts values from the annotation mirror value.- Parameters:
am- the annotation mirrorelements- the elements- Returns:
- the extracted values
-
extractValues
public static Map<String,String> extractValues(Map<? extends ExecutableElement, ? extends AnnotationValue> values) Extracts values from the annotation element values.- Parameters:
values- the element values- Returns:
- the extracted values
-
extractValue
Extracts the singularvalue()value. Return value will always be non-null.- Parameters:
am- the annotation mirrorelements- the elements- Returns:
- the extracted values
-
createTypedElementNameFromElement
Creates an instance of aTypedElementNamegiven its type and variable element from annotation processing.- Parameters:
v- the element (from annotation processing)elements- the elements- Returns:
- the created instance
-
generatedStickerFor
Produces the generated sticker annotation attribute contents.- Parameters:
generatorClassTypeName- the generator class type nameversionId- the generator version identifier- Returns:
- the generated sticker
-
copyrightHeaderFor
Produces the generated copy right header on code generated artifacts.- Parameters:
generatorClassTypeName- the generator class type name- Returns:
- the generated comments
-