Skip to content
This repository has been archived by the owner on Jan 22, 2019. It is now read-only.

Add Support for InternetDomainName #50

Closed
sdavids opened this issue Oct 1, 2014 · 4 comments
Closed

Add Support for InternetDomainName #50

sdavids opened this issue Oct 1, 2014 · 4 comments
Milestone

Comments

@sdavids
Copy link

sdavids commented Oct 1, 2014

com.google.common.net.InternetDomainName

InternetDomainName#from(String domain) <-> InternetDomainName#toString()

@sdavids
Copy link
Author

sdavids commented Oct 1, 2014

@ Serializer @

if (InternetDomainName.class.isAssignableFrom(raw)) {
  return ToStringSerializer.instance;
}

@ Deserializer @

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonToken;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
import com.google.common.net.InternetDomainName;

import java.io.IOException;

public final class InternetDomainNameDeserializer extends StdDeserializer<InternetDomainName> {

  public final static InternetDomainNameDeserializer std = new InternetDomainNameDeserializer();

  private static final long serialVersionUID = -966108494654118749L;

  public InternetDomainNameDeserializer() {
    super(InternetDomainName.class);
  }

  @Override
  public InternetDomainName deserialize(JsonParser jp, DeserializationContext ctxt)
      throws IOException {
    JsonToken t = jp.getCurrentToken();
    if (t != JsonToken.VALUE_STRING) {
      throw ctxt.wrongTokenException(jp, JsonToken.VALUE_STRING, null);
    }
    return InternetDomainName.from(jp.getText().trim());
  }
}

@cowtowncoder cowtowncoder added this to the 2.4.3 milestone Oct 2, 2014
@cowtowncoder
Copy link
Member

Yes, makes sense. Deserialization was already working due to existence of single-String-arg constructor, but I improved handling a bit. Plus serialization was using bean accessors, which is sub-optimal anyway.

@sdavids
Copy link
Author

sdavids commented Oct 2, 2014

https://github.com/FasterXML/jackson-datatype-guava/blob/f883c5f9c2cfcf941f08cf1bd431c2928bbe9458/src/main/java/com/fasterxml/jackson/datatype/guava/deser/InternetDomainNameDeserializer.java

public InternetDomainNameDeserializer() { super(HostAndPort.class); }

……………………………………………………………..^^^

@@

Sebastian Davids=

@cowtowncoder
Copy link
Member

Thanks, will fix.

cowtowncoder added a commit that referenced this issue Oct 2, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants