1717package com .google .gson ;
1818
1919import java .lang .reflect .Field ;
20+ import java .util .Collections ;
21+ import java .util .List ;
2022import java .util .Locale ;
2123
2224/**
@@ -33,8 +35,8 @@ public enum FieldNamingPolicy implements FieldNamingStrategy {
3335 /** Using this naming policy with Gson will ensure that the field name is unchanged. */
3436 IDENTITY () {
3537 @ Override
36- public String translateName (Field f ) {
37- return f .getName ();
38+ public List < String > translateName (Field f ) {
39+ return Collections . singletonList ( f .getName () );
3840 }
3941 },
4042
@@ -51,8 +53,8 @@ public String translateName(Field f) {
5153 */
5254 UPPER_CAMEL_CASE () {
5355 @ Override
54- public String translateName (Field f ) {
55- return upperCaseFirstLetter (f .getName ());
56+ public List < String > translateName (Field f ) {
57+ return Collections . singletonList ( upperCaseFirstLetter (f .getName () ));
5658 }
5759 },
5860
@@ -71,8 +73,8 @@ public String translateName(Field f) {
7173 */
7274 UPPER_CAMEL_CASE_WITH_SPACES () {
7375 @ Override
74- public String translateName (Field f ) {
75- return upperCaseFirstLetter (separateCamelCase (f .getName (), ' ' ));
76+ public List < String > translateName (Field f ) {
77+ return Collections . singletonList ( upperCaseFirstLetter (separateCamelCase (f .getName (), ' ' ) ));
7678 }
7779 },
7880
@@ -93,8 +95,9 @@ public String translateName(Field f) {
9395 */
9496 UPPER_CASE_WITH_UNDERSCORES () {
9597 @ Override
96- public String translateName (Field f ) {
97- return separateCamelCase (f .getName (), '_' ).toUpperCase (Locale .ENGLISH );
98+ public List <String > translateName (Field f ) {
99+ return Collections .singletonList (
100+ separateCamelCase (f .getName (), '_' ).toUpperCase (Locale .ENGLISH ));
98101 }
99102 },
100103
@@ -113,8 +116,9 @@ public String translateName(Field f) {
113116 */
114117 LOWER_CASE_WITH_UNDERSCORES () {
115118 @ Override
116- public String translateName (Field f ) {
117- return separateCamelCase (f .getName (), '_' ).toLowerCase (Locale .ENGLISH );
119+ public List <String > translateName (Field f ) {
120+ return Collections .singletonList (
121+ separateCamelCase (f .getName (), '_' ).toLowerCase (Locale .ENGLISH ));
118122 }
119123 },
120124
@@ -140,8 +144,9 @@ public String translateName(Field f) {
140144 */
141145 LOWER_CASE_WITH_DASHES () {
142146 @ Override
143- public String translateName (Field f ) {
144- return separateCamelCase (f .getName (), '-' ).toLowerCase (Locale .ENGLISH );
147+ public List <String > translateName (Field f ) {
148+ return Collections .singletonList (
149+ separateCamelCase (f .getName (), '-' ).toLowerCase (Locale .ENGLISH ));
145150 }
146151 },
147152
@@ -167,8 +172,9 @@ public String translateName(Field f) {
167172 */
168173 LOWER_CASE_WITH_DOTS () {
169174 @ Override
170- public String translateName (Field f ) {
171- return separateCamelCase (f .getName (), '.' ).toLowerCase (Locale .ENGLISH );
175+ public List <String > translateName (Field f ) {
176+ return Collections .singletonList (
177+ separateCamelCase (f .getName (), '.' ).toLowerCase (Locale .ENGLISH ));
172178 }
173179 };
174180
0 commit comments