1
+ /*
2
+ * Echo Server API
3
+ * Echo Server API
4
+ *
5
+ * The version of the OpenAPI document: 0.1.0
6
+
7
+ *
8
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
9
+ * https://openapi-generator.tech
10
+ * Do not edit the class manually.
11
+ */
12
+
13
+ package org .openapitools .client ;
14
+
15
+ import java .io .IOException ;
16
+ import java .time .Instant ;
17
+ import java .time .OffsetDateTime ;
18
+ import java .time .ZoneId ;
19
+ import java .time .ZonedDateTime ;
20
+ import java .time .format .DateTimeFormatter ;
21
+ import java .time .temporal .Temporal ;
22
+ import java .time .temporal .TemporalAccessor ;
23
+ import java .util .function .BiFunction ;
24
+ import java .util .function .Function ;
25
+
26
+ import com .fasterxml .jackson .core .JsonParser ;
27
+ import com .fasterxml .jackson .databind .DeserializationContext ;
28
+ import com .fasterxml .jackson .datatype .jsr310 .JavaTimeFeature ;
29
+ import com .fasterxml .jackson .datatype .jsr310 .deser .InstantDeserializer ;
30
+
31
+ @ javax .annotation .Generated (value = "org.openapitools.codegen.languages.JavaClientCodegen" , comments = "Generator version: 7.10.0-SNAPSHOT" )
32
+ public class RFC3339InstantDeserializer <T extends Temporal > extends InstantDeserializer <T > {
33
+
34
+ private final static boolean DEFAULT_NORMALIZE_ZONE_ID = JavaTimeFeature .NORMALIZE_DESERIALIZED_ZONE_ID .enabledByDefault ();
35
+ private final static boolean DEFAULT_ALWAYS_ALLOW_STRINGIFIED_DATE_TIMESTAMPS
36
+ = JavaTimeFeature .ALWAYS_ALLOW_STRINGIFIED_DATE_TIMESTAMPS .enabledByDefault ();
37
+
38
+ public static final RFC3339InstantDeserializer <Instant > INSTANT = new RFC3339InstantDeserializer <>(
39
+ Instant .class , DateTimeFormatter .ISO_INSTANT ,
40
+ Instant ::from ,
41
+ a -> Instant .ofEpochMilli ( a .value ),
42
+ a -> Instant .ofEpochSecond ( a .integer , a .fraction ),
43
+ null ,
44
+ true , // yes, replace zero offset with Z
45
+ DEFAULT_NORMALIZE_ZONE_ID ,
46
+ DEFAULT_ALWAYS_ALLOW_STRINGIFIED_DATE_TIMESTAMPS
47
+ );
48
+
49
+ public static final RFC3339InstantDeserializer <OffsetDateTime > OFFSET_DATE_TIME = new RFC3339InstantDeserializer <>(
50
+ OffsetDateTime .class , DateTimeFormatter .ISO_OFFSET_DATE_TIME ,
51
+ OffsetDateTime ::from ,
52
+ a -> OffsetDateTime .ofInstant ( Instant .ofEpochMilli ( a .value ), a .zoneId ),
53
+ a -> OffsetDateTime .ofInstant ( Instant .ofEpochSecond ( a .integer , a .fraction ), a .zoneId ),
54
+ (d , z ) -> ( d .isEqual ( OffsetDateTime .MIN ) || d .isEqual ( OffsetDateTime .MAX ) ?
55
+ d :
56
+ d .withOffsetSameInstant ( z .getRules ().getOffset ( d .toLocalDateTime () ) ) ),
57
+ true , // yes, replace zero offset with Z
58
+ DEFAULT_NORMALIZE_ZONE_ID ,
59
+ DEFAULT_ALWAYS_ALLOW_STRINGIFIED_DATE_TIMESTAMPS
60
+ );
61
+
62
+ public static final RFC3339InstantDeserializer <ZonedDateTime > ZONED_DATE_TIME = new RFC3339InstantDeserializer <>(
63
+ ZonedDateTime .class , DateTimeFormatter .ISO_ZONED_DATE_TIME ,
64
+ ZonedDateTime ::from ,
65
+ a -> ZonedDateTime .ofInstant ( Instant .ofEpochMilli ( a .value ), a .zoneId ),
66
+ a -> ZonedDateTime .ofInstant ( Instant .ofEpochSecond ( a .integer , a .fraction ), a .zoneId ),
67
+ ZonedDateTime ::withZoneSameInstant ,
68
+ false , // keep zero offset and Z separate since zones explicitly supported
69
+ DEFAULT_NORMALIZE_ZONE_ID ,
70
+ DEFAULT_ALWAYS_ALLOW_STRINGIFIED_DATE_TIMESTAMPS
71
+ );
72
+
73
+ protected RFC3339InstantDeserializer (
74
+ Class <T > supportedType ,
75
+ DateTimeFormatter formatter ,
76
+ Function <TemporalAccessor , T > parsedToValue ,
77
+ Function <FromIntegerArguments , T > fromMilliseconds ,
78
+ Function <FromDecimalArguments , T > fromNanoseconds ,
79
+ BiFunction <T , ZoneId , T > adjust ,
80
+ boolean replaceZeroOffsetAsZ ,
81
+ boolean normalizeZoneId ,
82
+ boolean readNumericStringsAsTimestamp ) {
83
+ super (
84
+ supportedType ,
85
+ formatter ,
86
+ parsedToValue ,
87
+ fromMilliseconds ,
88
+ fromNanoseconds ,
89
+ adjust ,
90
+ replaceZeroOffsetAsZ ,
91
+ normalizeZoneId ,
92
+ readNumericStringsAsTimestamp
93
+ );
94
+ }
95
+
96
+ @ Override
97
+ protected T _fromString (JsonParser p , DeserializationContext ctxt , String string0 ) throws IOException {
98
+ return super ._fromString (p , ctxt , string0 .replace ( ' ' , 'T' ));
99
+ }
100
+ }
0 commit comments