File tree Expand file tree Collapse file tree 4 files changed +18
-32
lines changed
http-generator-client/src/main/java/io/avaje/http/generator/client
http-generator-core/src/main/java/io/avaje/http/generator/core
http-generator-javalin/src/main/java/io/avaje/http/generator/javalin
http-generator-nima/src/main/java/io/avaje/http/generator/helidon/nima Expand file tree Collapse file tree 4 files changed +18
-32
lines changed Original file line number Diff line number Diff line change 22
33import io .avaje .http .api .Client ;
44import io .avaje .http .generator .core .ControllerReader ;
5+ import io .avaje .http .generator .core .JsonBUtil ;
56import io .avaje .http .generator .core .ProcessingContext ;
67
78import javax .annotation .processing .AbstractProcessor ;
@@ -30,14 +31,7 @@ public class ClientProcessor extends AbstractProcessor {
3031 private final boolean useJsonB ;
3132
3233 public ClientProcessor () {
33- var jsonBOnClassPath = false ;
34- try {
35- Class .forName ("io.avaje.jsonb.Jsonb" );
36- jsonBOnClassPath = true ;
37- } catch (final ClassNotFoundException e ) {
38- // intentionally ignored
39- }
40- useJsonB = jsonBOnClassPath ;
34+ useJsonB = JsonBUtil .detectJsonb ();
4135 }
4236
4337 public ClientProcessor (boolean useJsonb ) {
Original file line number Diff line number Diff line change 88public class JsonBUtil {
99 private JsonBUtil () {}
1010
11+ /**
12+ * Return true if avaje-jsonb is detected in the classpath.
13+ */
14+ public static boolean detectJsonb () {
15+ try {
16+ Class .forName ("io.avaje.jsonb.Jsonb" );
17+ return true ;
18+ } catch (final ClassNotFoundException e ) {
19+ return false ;
20+ }
21+ }
22+
1123 public static Map <String , UType > jsonTypes (ControllerReader reader ) {
1224
1325 final Map <String , UType > jsonTypes = new LinkedHashMap <>();
Original file line number Diff line number Diff line change 11package io .avaje .http .generator .javalin ;
22
3- import io .avaje .http .generator .core .BaseProcessor ;
4- import io .avaje .http .generator .core .ControllerReader ;
5- import io .avaje .http .generator .core .PlatformAdapter ;
6- import io .avaje .http .generator .core .ProcessingContext ;
3+ import io .avaje .http .generator .core .*;
74
85import java .io .IOException ;
96
@@ -12,14 +9,7 @@ public class JavalinProcessor extends BaseProcessor {
129 private final boolean useJsonB ;
1310
1411 public JavalinProcessor () {
15- var jsonBOnClassPath = false ;
16- try {
17- Class .forName ("io.avaje.jsonb.Jsonb" );
18- jsonBOnClassPath = true ;
19- } catch (final ClassNotFoundException e ) {
20- // intentionally ignored
21- }
22- useJsonB = jsonBOnClassPath ;
12+ useJsonB = JsonBUtil .detectJsonb ();
2313 }
2414
2515 public JavalinProcessor (boolean useJsonb ) {
Original file line number Diff line number Diff line change 11package io .avaje .http .generator .helidon .nima ;
22
3- import io .avaje .http .generator .core .BaseProcessor ;
4- import io .avaje .http .generator .core .ControllerReader ;
5- import io .avaje .http .generator .core .PlatformAdapter ;
6- import io .avaje .http .generator .core .ProcessingContext ;
3+ import io .avaje .http .generator .core .*;
74
85import java .io .IOException ;
96
@@ -12,14 +9,7 @@ public class NimaProcessor extends BaseProcessor {
129 private final boolean jsonB ;
1310
1411 public NimaProcessor () {
15- var jsonBOnClassPath = false ;
16- try {
17- Class .forName ("io.avaje.jsonb.Jsonb" );
18- jsonBOnClassPath = true ;
19- } catch (final ClassNotFoundException e ) {
20- // intentionally ignored
21- }
22- jsonB = jsonBOnClassPath ;
12+ jsonB = JsonBUtil .detectJsonb ();
2313 }
2414
2515 public NimaProcessor (boolean useJsonb ) {
You can’t perform that action at this time.
0 commit comments