File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed
src/main/java/com/rethinkdb/net Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -45,9 +45,19 @@ public static JSONObject toJSON(ByteBuffer buf) {
4545 }
4646
4747 public static <T , P > T convertToPojo (Object value , Optional <Class <P >> pojoClass ) {
48- return !pojoClass .isPresent () || !(value instanceof Map )
49- ? (T ) value
50- : (T ) RethinkDB .getObjectMapper ().convertValue (value , pojoClass .get ());
48+ if (pojoClass .isPresent ()) {
49+ if (pojoClass .get ().isEnum ()) {
50+ Enum <?>[] enumConstants = ((Class <Enum <?>>) pojoClass .get ()).getEnumConstants ();
51+ for (Enum <?> enumConst : enumConstants ) {
52+ if (enumConst .name ().equals (value )) {
53+ return (T ) enumConst ;
54+ }
55+ }
56+ } else if (value instanceof Map ) {
57+ return (T ) RethinkDB .getObjectMapper ().convertValue (value , pojoClass .get ());
58+ }
59+ }
60+ return (T ) value ;
5161 }
5262
5363 public static byte [] toUTF8 (String s ) {
You can’t perform that action at this time.
0 commit comments