11package com .sap .cloud .sdk .services .openapi .apiclient ;
22
3- import java .lang .reflect .InvocationTargetException ;
43import java .util .List ;
54import java .util .ListIterator ;
65import java .util .function .UnaryOperator ;
@@ -70,13 +69,13 @@ class Jackson3 implements ConverterPatcher
7069 @ Override
7170 public <T > T patch ( @ Nonnull final T instance )
7271 {
73- // run the following code respectively if the classes were available:
74-
75- // Builder builder = ((JacksonJsonHttpMessageConverter) instance).getMapper().rebuild()
76- // .changeDefaultVisibility(v -> v
77- // .withGetterVisibility(JsonAutoDetect.Visibility.NONE)
78- // .withSetterVisibility(JsonAutoDetect.Visibility.NONE));
79- // return (T) new JacksonJsonHttpMessageConverter(builder);
72+ // run the following code respectively if the classes were available:
73+ //
74+ // Builder builder = ((JacksonJsonHttpMessageConverter) instance).getMapper().rebuild()
75+ // .changeDefaultVisibility(v -> v
76+ // .withGetterVisibility(JsonAutoDetect.Visibility.NONE)
77+ // .withSetterVisibility(JsonAutoDetect.Visibility.NONE));
78+ // return (T) new JacksonJsonHttpMessageConverter(builder);
8079
8180 final String springJacksonConverter =
8281 "org.springframework.http.converter.json.JacksonJsonHttpMessageConverter" ;
@@ -92,17 +91,13 @@ public <T> T patch( @Nonnull final T instance )
9291 .rebuild ();
9392 builder = builder .changeDefaultVisibility (vc );
9493 try {
95- final String jackson2SerName = "com.fasterxml.jackson.databind.JsonSerializable" ;
96- final String serializerName = "tools.jackson.databind.ser.jackson.RawSerializer" ;
97- final String moduleName = "tools.jackson.databind.module.SimpleModule" ;
98- final Class <?> jackson2ser = Class .forName (jackson2SerName );
99- final Object serializer =
100- Class
101- .forName (serializerName )
102- .getConstructor (Class .class )
103- .newInstance (jackson2ser );
104- Object module =
105- Class .forName (moduleName ).getConstructor ().newInstance ();
94+ final String jackson2SerName = "com.fasterxml.jackson.databind.JsonSerializable" ;
95+ final String serializerName = "tools.jackson.databind.ser.jackson.RawSerializer" ;
96+ final String moduleName = "tools.jackson.databind.module.SimpleModule" ;
97+ final Class <?> jackson2ser = Class .forName (jackson2SerName );
98+ final Object serializer =
99+ Class .forName (serializerName ).getConstructor (Class .class ).newInstance (jackson2ser );
100+ Object module = Class .forName (moduleName ).getConstructor ().newInstance ();
106101 module =
107102 module .getClass ().getMethod ("addSerializer" , serializer .getClass ()).invoke (module , serializer );
108103 builder =
@@ -111,8 +106,7 @@ public <T> T patch( @Nonnull final T instance )
111106 .getMethod ("addModule" , module .getClass ())
112107 .invoke (builder , module );
113108 }
114- catch ( final
115- Exception e ) {
109+ catch ( final Exception e ) {
116110 log .debug ("Could not find Jackson2 JsonSerializable class to add ToStringSerializer." , e );
117111 }
118112 return (T ) new org .springframework .http .converter .json .JacksonJsonHttpMessageConverter (builder );
0 commit comments