File tree Expand file tree Collapse file tree 2 files changed +37
-1
lines changed
main/java/io/avaje/jsonb/generator
test/java/io/avaje/jsonb/generator Expand file tree Collapse file tree 2 files changed +37
-1
lines changed Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ class NamingConventionReader {
19
19
if (JSON_ANNOTATION .equals (mirror .getAnnotationType ().toString ())) {
20
20
for (Map .Entry <? extends ExecutableElement , ? extends AnnotationValue > entry : mirror .getElementValues ().entrySet ()) {
21
21
if (entry .getKey ().toString ().equals (NAMING_ATTRIBUTE )) {
22
- namingConvention = NamingConvention .of (Json . Naming . valueOf (entry .getValue ().toString ()));
22
+ namingConvention = NamingConvention .of (naming (entry .getValue ().toString ()));
23
23
} else if (entry .getKey ().toString ().equals (TYPEPROPERTY_ATTRIBUTE )) {
24
24
typeProperty = Util .trimQuotes (entry .getValue ().toString ());
25
25
}
@@ -28,6 +28,14 @@ class NamingConventionReader {
28
28
}
29
29
}
30
30
31
+ static Json .Naming naming (String entry ) {
32
+ int pos = entry .lastIndexOf ('.' );
33
+ if (pos > -1 ) {
34
+ entry = entry .substring (pos + 1 );
35
+ }
36
+ return Json .Naming .valueOf (entry );
37
+ }
38
+
31
39
NamingConvention get () {
32
40
return namingConvention != null ? namingConvention : NamingConvention .of (Json .Naming .Match );
33
41
}
Original file line number Diff line number Diff line change
1
+ package io .avaje .jsonb .generator ;
2
+
3
+ import io .avaje .jsonb .Json ;
4
+ import org .junit .jupiter .api .Test ;
5
+
6
+ import static org .assertj .core .api .Assertions .assertThat ;
7
+
8
+ class NamingConventionReaderTest {
9
+
10
+ @ Test
11
+ void naming_expected () {
12
+ Json .Naming naming = NamingConventionReader .naming ("LowerUnderscore" );
13
+ assertThat (naming ).isEqualTo (Json .Naming .LowerUnderscore );
14
+ }
15
+
16
+ @ Test
17
+ void naming_namingWithPrefix () {
18
+ Json .Naming naming = NamingConventionReader .naming ("Naming.LowerUnderscore" );
19
+ assertThat (naming ).isEqualTo (Json .Naming .LowerUnderscore );
20
+
21
+ naming = NamingConventionReader .naming ("io.avaje.jsonb.Json.Naming.LowerUnderscore" );
22
+ assertThat (naming ).isEqualTo (Json .Naming .LowerUnderscore );
23
+
24
+ naming = NamingConventionReader .naming ("io.avaje.jsonb.Json.Naming.io.avaje.jsonb.Json.Naming.LowerUnderscore" );
25
+ assertThat (naming ).isEqualTo (Json .Naming .LowerUnderscore );
26
+ }
27
+
28
+ }
You can’t perform that action at this time.
0 commit comments