-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9ce3d1c
commit 052be02
Showing
7 changed files
with
95 additions
and
42 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
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
43 changes: 43 additions & 0 deletions
43
src/main/java/com/fasterxml/jackson/databind/ext/Java7Handlers.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,43 @@ | ||
package com.fasterxml.jackson.databind.ext; | ||
|
||
import com.fasterxml.jackson.databind.JsonDeserializer; | ||
import com.fasterxml.jackson.databind.JsonSerializer; | ||
import com.fasterxml.jackson.databind.util.ClassUtil; | ||
|
||
/** | ||
* To support Java7-incomplete platforms, we will offer support for JDK 7 | ||
* datatype(s) (that is, {@link java.nio.file.Path} through this class, loaded | ||
* dynamically; if loading fails, support will be missing. | ||
* This class is the non-JDK-7-dependent API, and {@link Java7HandlersImpl} is | ||
* JDK7-dependent implementation of functionality. | ||
* | ||
* @since 2.10 (cleaved off of {@link Java7Support}) | ||
*/ | ||
public abstract class Java7Handlers | ||
{ | ||
private final static Java7Handlers IMPL; | ||
|
||
static { | ||
Java7Handlers impl = null; | ||
try { | ||
Class<?> cls = Class.forName("com.fasterxml.jackson.databind.ext.Java7HandlersImpl"); | ||
impl = (Java7Handlers) ClassUtil.createInstance(cls, false); | ||
} catch (Throwable t) { | ||
// 09-Sep-2019, tatu: Could choose not to log this, but since this is less likely | ||
// to miss (than annotations), do it | ||
java.util.logging.Logger.getLogger(Java7Handlers.class.getName()) | ||
.warning("Unable to load JDK7 types (java.nio.file.Path): no Java7 type support added"); | ||
} | ||
IMPL = impl; | ||
} | ||
|
||
public static Java7Handlers instance() { | ||
return IMPL; | ||
} | ||
|
||
public abstract Class<?> getClassJavaNioFilePath(); | ||
|
||
public abstract JsonDeserializer<?> getDeserializerForJavaNioFilePath(Class<?> rawType); | ||
|
||
public abstract JsonSerializer<?> getSerializerForJavaNioFilePath(Class<?> rawType); | ||
} |
33 changes: 33 additions & 0 deletions
33
src/main/java/com/fasterxml/jackson/databind/ext/Java7HandlersImpl.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,33 @@ | ||
package com.fasterxml.jackson.databind.ext; | ||
|
||
import java.nio.file.Path; | ||
|
||
import com.fasterxml.jackson.databind.JsonDeserializer; | ||
import com.fasterxml.jackson.databind.JsonSerializer; | ||
|
||
/** | ||
* @since 2.10 | ||
*/ | ||
public class Java7HandlersImpl extends Java7Handlers | ||
{ | ||
@Override | ||
public Class<?> getClassJavaNioFilePath() { | ||
return Path.class; | ||
} | ||
|
||
@Override | ||
public JsonDeserializer<?> getDeserializerForJavaNioFilePath(Class<?> rawType) { | ||
if (rawType == Path.class) { | ||
return new NioPathDeserializer(); | ||
} | ||
return null; | ||
} | ||
|
||
@Override | ||
public JsonSerializer<?> getSerializerForJavaNioFilePath(Class<?> rawType) { | ||
if (Path.class.isAssignableFrom(rawType)) { | ||
return new NioPathSerializer(); | ||
} | ||
return null; | ||
} | ||
} |
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