-
-
Notifications
You must be signed in to change notification settings - Fork 138
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Base deserializer and try-catch block removed, no need to try to wrap…
… anything, expected pattern is to let exception pass through if any.
- Loading branch information
1 parent
1bd02ba
commit 8f52e52
Showing
5 changed files
with
48 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
...java/com/fasterxml/jackson/dataformat/avro/jsr310/deser/AvroJavaTimeDeserializerBase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.fasterxml.jackson.dataformat.avro.jsr310.deser; | ||
|
||
import com.fasterxml.jackson.core.JsonParser; | ||
import com.fasterxml.jackson.databind.DeserializationContext; | ||
import com.fasterxml.jackson.databind.deser.std.StdScalarDeserializer; | ||
import com.fasterxml.jackson.databind.type.LogicalType; | ||
|
||
import java.io.IOException; | ||
import java.time.ZoneId; | ||
|
||
public abstract class AvroJavaTimeDeserializerBase<T> extends StdScalarDeserializer<T> { | ||
|
||
protected AvroJavaTimeDeserializerBase(Class<T> supportedType) { | ||
super(supportedType); | ||
} | ||
|
||
@Override | ||
public LogicalType logicalType() { | ||
return LogicalType.DateTime; | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
@Override | ||
public T deserialize(JsonParser p, DeserializationContext context) throws IOException { | ||
final ZoneId defaultZoneId = context.getTimeZone().toZoneId().normalized(); | ||
switch (p.getCurrentToken()) { | ||
case VALUE_NUMBER_INT: | ||
return fromLong(p.getLongValue(), defaultZoneId); | ||
} | ||
return (T) context.handleUnexpectedToken(_valueClass, p); | ||
} | ||
|
||
protected abstract T fromLong(long longValue, ZoneId defaultZoneId); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters