Package com.alibaba.fastjson.serializer
Class GuavaCodec
- java.lang.Object
-
- com.alibaba.fastjson.serializer.GuavaCodec
-
- All Implemented Interfaces:
ObjectDeserializer,ObjectSerializer
public class GuavaCodec extends Object implements ObjectSerializer, ObjectDeserializer
Created by wenshao on 15/01/2017.
-
-
Field Summary
Fields Modifier and Type Field Description static GuavaCodecinstance
-
Constructor Summary
Constructors Constructor Description GuavaCodec()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> Tdeserialze(DefaultJSONParser parser, Type type, Object fieldName)fastjson invokes this call-back method during deserialization when it encounters a field of the specified type.intgetFastMatchToken()voidwrite(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features)fastjson invokes this call-back method during serialization when it encounters a field of the specified type.
-
-
-
Field Detail
-
instance
public static GuavaCodec instance
-
-
Method Detail
-
write
public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException
Description copied from interface:ObjectSerializerfastjson invokes this call-back method during serialization when it encounters a field of the specified type.- Specified by:
writein interfaceObjectSerializerobject- src the object that needs to be converted to Json.fieldName- parent object field namefieldType- parent object field typefeatures- parent object field serializer features- Throws:
IOException
-
deserialze
public <T> T deserialze(DefaultJSONParser parser, Type type, Object fieldName)
Description copied from interface:ObjectDeserializerfastjson invokes this call-back method during deserialization when it encounters a field of the specified type.In the implementation of this call-back method, you should consider invoking
JSON.parseObject(String, Type, Feature[])method to create objects for any non-trivial field of the returned object.- Specified by:
deserialzein interfaceObjectDeserializer- Parameters:
parser- context DefaultJSONParser being deserializedtype- The type of the Object to deserialize tofieldName- parent object field name- Returns:
- a deserialized object of the specified type which is a subclass of
T
-
getFastMatchToken
public int getFastMatchToken()
- Specified by:
getFastMatchTokenin interfaceObjectDeserializer
-
-