This repository has been archived by the owner on Jan 20, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 52
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
7b5c7b7
commit f883c5f
Showing
8 changed files
with
79 additions
and
19 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
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
24 changes: 24 additions & 0 deletions
24
src/main/java/com/fasterxml/jackson/datatype/guava/deser/InternetDomainNameDeserializer.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,24 @@ | ||
package com.fasterxml.jackson.datatype.guava.deser; | ||
|
||
import java.io.IOException; | ||
|
||
import com.google.common.net.HostAndPort; | ||
import com.google.common.net.InternetDomainName; | ||
|
||
import com.fasterxml.jackson.databind.DeserializationContext; | ||
import com.fasterxml.jackson.databind.deser.std.FromStringDeserializer; | ||
|
||
public class InternetDomainNameDeserializer extends FromStringDeserializer<InternetDomainName> | ||
{ | ||
private static final long serialVersionUID = 1L; | ||
|
||
public final static InternetDomainNameDeserializer std = new InternetDomainNameDeserializer(); | ||
|
||
public InternetDomainNameDeserializer() { super(HostAndPort.class); } | ||
|
||
@Override | ||
protected InternetDomainName _deserialize(String value, DeserializationContext ctxt) | ||
throws IOException { | ||
return InternetDomainName.from(value); | ||
} | ||
} |
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
25 changes: 25 additions & 0 deletions
25
src/test/java/com/fasterxml/jackson/datatype/guava/ScalarTypesTest.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,25 @@ | ||
package com.fasterxml.jackson.datatype.guava; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.google.common.net.InternetDomainName; | ||
|
||
public class ScalarTypesTest extends ModuleTestBase | ||
{ | ||
private final ObjectMapper MAPPER = mapperWithModule(); | ||
|
||
public void testInternetDomainNameSerialization() throws Exception | ||
{ | ||
final String INPUT = "google.com"; | ||
InternetDomainName name = InternetDomainName.from(INPUT); | ||
assertEquals(quote(INPUT), MAPPER.writeValueAsString(name)); | ||
} | ||
|
||
public void testInternetDomainNameDeserialization() throws Exception | ||
{ | ||
final String INPUT = "google.com"; | ||
// InternetDomainName name = MAPPER.readValue(quote(INPUT), InternetDomainName.class); | ||
InternetDomainName name = new ObjectMapper().readValue(quote(INPUT), InternetDomainName.class); | ||
assertNotNull(name); | ||
assertEquals(INPUT, name.toString()); | ||
} | ||
} |
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