From 2467c8e22383d2ca70f2d8a751fff5d159cb7122 Mon Sep 17 00:00:00 2001 From: Ethan McCue Date: Sun, 23 Jan 2022 12:04:46 -0500 Subject: [PATCH] Support making an magic bean in the unnamed package --- .../mccue/magicbean/processor/AnnotationProcessor.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/dev/mccue/magicbean/processor/AnnotationProcessor.java b/src/main/java/dev/mccue/magicbean/processor/AnnotationProcessor.java index b1694d6..efebd49 100644 --- a/src/main/java/dev/mccue/magicbean/processor/AnnotationProcessor.java +++ b/src/main/java/dev/mccue/magicbean/processor/AnnotationProcessor.java @@ -204,6 +204,14 @@ public boolean process( return true; } + String packageName; + if (packageElement.isUnnamed()) { + packageName = null; + } + else { + packageName = packageElement.toString(); + } + String selfExpr; if (typeElement.getAnnotation(MagicBean.class).useTypeSafeCast()) { @@ -298,7 +306,7 @@ public boolean process( try { var file = filer.createSourceFile( - packageElement + "." + className + "BeanOps", + (packageName == null ? "" : packageName + ".") + className + "BeanOps", element ); try (var writer = file.openWriter()) {