48
48
import software .amazon .awssdk .protocols .json .internal .MarshallerUtil ;
49
49
import software .amazon .awssdk .protocols .json .internal .unmarshall .document .DocumentUnmarshaller ;
50
50
import software .amazon .awssdk .protocols .jsoncore .JsonNode ;
51
- import software .amazon .awssdk .protocols .jsoncore .JsonNodeParser ;
52
51
import software .amazon .awssdk .protocols .jsoncore .JsonValueNodeFactory ;
53
52
import software .amazon .awssdk .utils .Lazy ;
54
53
import software .amazon .awssdk .utils .builder .Buildable ;
59
58
*/
60
59
@ SdkInternalApi
61
60
@ ThreadSafe
62
- public class JsonProtocolUnmarshaller {
61
+ public final class JsonProtocolUnmarshaller {
63
62
private static final Lazy <DefaultProtocolUnmarshallDependencies > DEFAULT_DEPENDENCIES =
64
63
new Lazy <>(JsonProtocolUnmarshaller ::newProtocolUnmarshallDependencies );
65
64
66
65
private final JsonUnmarshallerRegistry registry ;
67
66
private final JsonUnmarshallingParser unmarshallingParser ;
68
- private final JsonNodeParser parser ;
69
67
70
68
private JsonProtocolUnmarshaller (Builder builder ) {
71
69
ProtocolUnmarshallDependencies dependencies = builder .protocolUnmarshallDependencies ;
72
70
this .registry = dependencies .jsonUnmarshallerRegistry ();
73
- if (builder .enableFastUnmarshalling ) {
74
- this .unmarshallingParser = JsonUnmarshallingParser .builder ()
75
- .jsonValueNodeFactory (dependencies .nodeValueFactory ())
76
- .jsonFactory (dependencies .jsonFactory ())
77
- .unmarshallerRegistry (dependencies .jsonUnmarshallerRegistry ())
78
- .defaultTimestampFormat (dependencies .timestampFormats ()
79
- .get (MarshallLocation .PAYLOAD ))
80
-
81
- .build ();
82
- this .parser = null ;
83
- } else {
84
- this .unmarshallingParser = null ;
85
- this .parser = createParser (builder , dependencies );
86
- }
87
- }
71
+ this .unmarshallingParser = JsonUnmarshallingParser .builder ()
72
+ .jsonValueNodeFactory (dependencies .nodeValueFactory ())
73
+ .jsonFactory (dependencies .jsonFactory ())
74
+ .unmarshallerRegistry (dependencies .jsonUnmarshallerRegistry ())
75
+ .defaultTimestampFormat (dependencies .timestampFormats ()
76
+ .get (MarshallLocation .PAYLOAD ))
88
77
89
- private JsonNodeParser createParser (Builder builder , ProtocolUnmarshallDependencies dependencies ) {
90
- if (builder .parser != null ) {
91
- return builder .parser ;
92
- }
93
- return JsonNodeParser
94
- .builder ()
95
- .jsonFactory (dependencies .jsonFactory ())
96
- .jsonValueNodeFactory (dependencies .nodeValueFactory ())
97
- .build ();
78
+ .build ();
98
79
}
99
80
100
81
public static DefaultProtocolUnmarshallDependencies defaultProtocolUnmarshallDependencies () {
@@ -239,15 +220,6 @@ public T unmarshall(JsonUnmarshallerContext context,
239
220
240
221
public <TypeT extends SdkPojo > TypeT unmarshall (SdkPojo sdkPojo ,
241
222
SdkHttpFullResponse response ) throws IOException {
242
- if (this .unmarshallingParser != null ) {
243
- return fastUnmarshall (sdkPojo , response );
244
- }
245
- JsonNode jsonNode = hasJsonPayload (sdkPojo , response ) ? parser .parse (response .content ().get ()) : null ;
246
- return unmarshall (sdkPojo , response , jsonNode );
247
- }
248
-
249
- private <TypeT extends SdkPojo > TypeT fastUnmarshall (SdkPojo sdkPojo ,
250
- SdkHttpFullResponse response ) throws IOException {
251
223
if (!hasJsonPayload (sdkPojo , response )) {
252
224
return unmarshallResponse (sdkPojo , response );
253
225
}
@@ -453,23 +425,11 @@ public static JsonUnmarshallerRegistry timestampFormatRegistryFactory(
453
425
* Builder for {@link JsonProtocolUnmarshaller}.
454
426
*/
455
427
public static final class Builder {
456
-
457
- private JsonNodeParser parser ;
458
428
private ProtocolUnmarshallDependencies protocolUnmarshallDependencies ;
459
- private boolean enableFastUnmarshalling = false ;
460
429
461
430
private Builder () {
462
431
}
463
432
464
- /**
465
- * @param parser JSON parser to use.
466
- * @return This builder for method chaining.
467
- */
468
- public Builder parser (JsonNodeParser parser ) {
469
- this .parser = parser ;
470
- return this ;
471
- }
472
-
473
433
/**
474
434
* @param formats The default timestamp formats for each location in the HTTP response.
475
435
* @return This builder for method chaining.
@@ -491,15 +451,6 @@ public Builder protocolUnmarshallDependencies(
491
451
return this ;
492
452
}
493
453
494
- /**
495
- * @param enableFastUnmarshalling Whether to enable the fast unmarshalling codepath. Default to {@code false}.
496
- * @return This builder for method chaining.
497
- */
498
- public Builder enableFastUnmarshalling (boolean enableFastUnmarshalling ) {
499
- this .enableFastUnmarshalling = enableFastUnmarshalling ;
500
- return this ;
501
- }
502
-
503
454
/**
504
455
* @return New instance of {@link JsonProtocolUnmarshaller}.
505
456
*/
0 commit comments