Avoid creating a nested group for an Enum

Previously, an Enum that is defined as an inner class of a
@ConfigurationProperties pojo was wrongly detected as an nested group.

This case is now handled explicitly and covered by a test.

Fixes gh-1971
This commit is contained in:
Stephane Nicoll
2014-11-21 17:20:35 +01:00
parent 5f673c9e84
commit 32efff3f30
3 changed files with 20 additions and 1 deletions

View File

@@ -34,6 +34,7 @@ import javax.lang.model.SourceVersion;
import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.AnnotationValue;
import javax.lang.model.element.Element;
import javax.lang.model.element.ElementKind;
import javax.lang.model.element.ExecutableElement;
import javax.lang.model.element.Modifier;
import javax.lang.model.element.TypeElement;
@@ -207,7 +208,8 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor
if (returnType != null && returnType instanceof TypeElement
&& annotation == null) {
TypeElement returns = (TypeElement) returnType;
if (this.typeUtils.isEnclosedIn(returnType, element) || isNested) {
if ((this.typeUtils.isEnclosedIn(returnType, element) && returnType.getKind() != ElementKind.ENUM)
|| isNested) {
String nestedPrefix = ConfigurationMetadata
.nestedPrefix(prefix, name);
this.metadata.add(ItemMetadata.newGroup(nestedPrefix,