Created
November 11, 2013 00:38
-
-
Save volgar1x/7405966 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
package org.photon; | |
import com.fasterxml.jackson.core.Version; | |
import com.fasterxml.jackson.databind.AnnotationIntrospector; | |
import com.fasterxml.jackson.databind.introspect.Annotated; | |
import com.fasterxml.jackson.databind.introspect.AnnotatedMember; | |
public class FlatJsonIntrospector extends AnnotationIntrospector { | |
@Override | |
public Version version() { | |
return FlatJsonModule.VERSION; | |
} | |
@Override | |
public Object findSerializer(Annotated am) { | |
Object serializer = super.findSerializer(am); | |
if (serializer == null) { | |
if (am.hasAnnotation(ManyToOne.class)) { | |
serializer = Serializers.ManyToOne.class; | |
} else if (am.hasAnnotation(OneToMany.class)) { | |
serializer = Serializers.OneToMany.class; | |
} | |
} | |
return serializer; | |
} | |
@Override | |
public Object findDeserializer(Annotated am) { | |
Object deserializer = super.findSerializer(am); | |
if (deserializer == null) { | |
if (am.hasAnnotation(ManyToOne.class)) { | |
deserializer = new Deserializers.ManyToOne((AnnotatedMember) am); | |
} else if (am.hasAnnotation(OneToMany.class)) { | |
deserializer = new Deserializers.OneToMany((AnnotatedMember) am); | |
} | |
} | |
return deserializer; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment