File tree Expand file tree Collapse file tree 7 files changed +25
-33
lines changed
src/main/java/io/avaje/jsonb/generator Expand file tree Collapse file tree 7 files changed +25
-33
lines changed Original file line number Diff line number Diff line change 1111 <name >avaje jsonb generator</name >
1212 <description >annotation processor generating source code json adapters for avaje-jsonb</description >
1313 <properties >
14- <avaje .prisms.version>2.0-RC1 </avaje .prisms.version>
14+ <avaje .prisms.version>2.0-RC2 </avaje .prisms.version>
1515 </properties >
1616
1717 <licenses >
Original file line number Diff line number Diff line change @@ -12,14 +12,15 @@ final class AdapterName {
1212 String originPackage = APContext .elements ().getPackageOf (beanReader .beanType ()).getQualifiedName ().toString ();
1313 var name = shortName (beanReader .beanType ());
1414 shortName = name .substring (0 , name .length () - 1 );
15- if (beanReader .isPkgPrivate ()) {
15+ if (beanReader .isPkgPrivate () || "" . equals ( originPackage ) ) {
1616 this .adapterPackage = originPackage ;
17- } else if ("" .equals (originPackage )) {
18- this .adapterPackage = "jsonb" ;
1917 } else {
2018 this .adapterPackage = ProcessingContext .isImported (beanReader .beanType ()) ? originPackage + ".jsonb" : originPackage ;
2119 }
22- this .fullName = adapterPackage + "." + shortName + "JsonAdapter" ;
20+ this .fullName =
21+ adapterPackage .isBlank ()
22+ ? shortName + "JsonAdapter"
23+ : adapterPackage + "." + shortName + "JsonAdapter" ;
2324 }
2425
2526 private String shortName (TypeElement origin ) {
Original file line number Diff line number Diff line change @@ -49,10 +49,20 @@ String fullName(boolean pkgPrivate) {
4949 var everyType = new ArrayList <>(allTypes );
5050 everyType .addAll (factoryTypes );
5151 String topPackage = TopPackage .of (everyType );
52- if (!pkgPrivate && !topPackage .endsWith (".jsonb" )) {
52+ var defaultPackage =
53+ !topPackage .contains ("." )
54+ && APContext .getProjectModuleElement ().isUnnamed ()
55+ && APContext .elements ().getPackageElement (topPackage ) == null ;
56+ if (!defaultPackage && !pkgPrivate && !topPackage .endsWith (".jsonb" ) && topPackage .contains ("." )) {
5357 topPackage += ".jsonb" ;
5458 }
55- if (pkgPrivate ) {
59+ if (!defaultPackage && !topPackage .contains ("." )) {
60+ topPackage += "jsonb" ;
61+ }
62+
63+ if (defaultPackage ) {
64+ fullName = "GeneratedJsonComponent" ;
65+ } else if (pkgPrivate ) {
5666 fullName = topPackage + "." + name (topPackage ) + "JsonComponent" ;
5767 } else if (APContext .isTestCompilation ()) {
5868 fullName = topPackage + ".TestJsonComponent" ;
Original file line number Diff line number Diff line change @@ -130,6 +130,8 @@ private void writeImports() {
130130 }
131131
132132 private void writePackage () {
133- writer .append ("package %s;" , adapterPackage ).eol ().eol ();
133+ if (!adapterPackage .isBlank ()) {
134+ writer .append ("package %s;" , adapterPackage ).eol ().eol ();
135+ }
134136 }
135137}
Original file line number Diff line number Diff line change 44
55final class TopPackage {
66
7- private String topPackage = "" ;
7+ private String topPackage ;
88
99 static String of (Collection <String > values ) {
1010 return new TopPackage (values ).value ();
@@ -16,7 +16,7 @@ private String value() {
1616
1717 private TopPackage (Collection <String > values ) {
1818 for (String pkg : values ) {
19- topPackage = Util .commonParent (topPackage , pkg );
19+ topPackage = ProcessorUtils .commonParent (topPackage , pkg );
2020 }
2121 }
2222}
Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ && importDifferentPackage(type, packageName)
3030 }
3131
3232 private static boolean importDifferentPackage (String type , String packageName ) {
33- return type .replace (packageName + '.' , "" ).indexOf ('.' ) > 0 ;
33+ return packageName . isBlank () || type .replace (packageName + '.' , "" ).indexOf ('.' ) > 0 ;
3434 }
3535
3636 private static boolean importJavaLangSubpackage (String type ) {
@@ -111,27 +111,6 @@ private static String cutAnnotations(String input) {
111111 return cutAnnotations (result );
112112 }
113113
114- /** Return the common parent package. */
115- static String commonParent (String currentTop , String aPackage ) {
116- if (aPackage == null ) return currentTop ;
117- if (currentTop .isBlank ()) return packageOf (aPackage );
118- if (aPackage .startsWith (currentTop )) {
119- return currentTop ;
120- }
121- int next ;
122- do {
123- next = currentTop .lastIndexOf ('.' );
124- if (next > -1 ) {
125- currentTop = currentTop .substring (0 , next );
126- if (aPackage .startsWith (currentTop )) {
127- return currentTop ;
128- }
129- }
130- } while (next > -1 );
131-
132- return currentTop ;
133- }
134-
135114 static String initCap (String input ) {
136115 if (input .length () < 2 ) {
137116 return input .toUpperCase ();
Original file line number Diff line number Diff line change 2424 <properties >
2525 <surefire .useModulePath>false</surefire .useModulePath>
2626 <nexus .staging.autoReleaseAfterClose>true</nexus .staging.autoReleaseAfterClose>
27- <spi .version>2.13 </spi .version>
27+ <spi .version>2.14-RC1 </spi .version>
2828 <project .build.outputTimestamp>2025-12-01T15:29:52Z</project .build.outputTimestamp>
2929 </properties >
3030
You can’t perform that action at this time.
0 commit comments