Skip to content

Commit

Permalink
Get element type without annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
radcortez committed Apr 18, 2023
1 parent a8d5a80 commit 3e87a01
Showing 1 changed file with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,6 @@ private List<ConfigDocItem> recursivelyFindConfigItems(Element element, String r
String name = null;
String defaultValue = NO_DEFAULT;
String defaultValueDoc = EMPTY;
final TypeMirror typeMirror = unwrapTypeMirror(enclosedElement.asType());
String type = typeMirror.toString();
List<String> acceptedValues = null;
final TypeElement clazz = (TypeElement) element;
final String fieldName = enclosedElement.getSimpleName().toString();
Expand Down Expand Up @@ -250,6 +248,9 @@ private List<ConfigDocItem> recursivelyFindConfigItems(Element element, String r
defaultValue = EMPTY;
}

TypeMirror typeMirror = unwrapTypeMirror(enclosedElement.asType());
String type = getType(typeMirror);

if (isConfigGroup(type)) {
List<ConfigDocItem> groupConfigItems = readConfigGroupItems(configPhase, rootName, name, type,
configSection, withinAMap, generateSeparateConfigGroupDocsFiles);
Expand Down Expand Up @@ -387,6 +388,15 @@ private TypeMirror unwrapTypeMirror(TypeMirror typeMirror) {
return typeMirror;
}

private String getType(TypeMirror typeMirror) {
if (typeMirror instanceof DeclaredType) {
DeclaredType declaredType = (DeclaredType) typeMirror;
TypeElement typeElement = (TypeElement) declaredType.asElement();
return typeElement.getQualifiedName().toString();
}
return typeMirror.toString();
}

private boolean isConfigGroup(String type) {
if (type.startsWith("java.") || PRIMITIVE_TYPES.contains(type)) {
return false;
Expand Down

0 comments on commit 3e87a01

Please sign in to comment.