Class GsonCodec<T>

java.lang.Object
io.datarouter.gson.codec.GsonCodec<T>
All Implemented Interfaces:
io.datarouter.bytes.Codec<T,String>

public class GsonCodec<T> extends Object implements io.datarouter.bytes.Codec<T,String>
Create a single object that can convert a single class to and from json.
  • Nested Class Summary

    Nested classes/interfaces inherited from interface io.datarouter.bytes.Codec

    io.datarouter.bytes.Codec.FunctionalCodec<A extends Object,B extends Object>, io.datarouter.bytes.Codec.NullPassthroughCodec<A extends Object,B extends Object>
  • Field Summary

    Fields inherited from interface io.datarouter.bytes.Codec

    IDENTITY_INSTANCE
  • Constructor Summary

    Constructors
    Constructor
    Description
    GsonCodec(com.google.gson.Gson gson, Class<T> cls)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    decode(String encodedValue)
     
    encode(T value)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface io.datarouter.bytes.Codec

    encodeAndDecode
  • Constructor Details

    • GsonCodec

      public GsonCodec(com.google.gson.Gson gson, Class<T> cls)
  • Method Details

    • encode

      public String encode(T value)
      Specified by:
      encode in interface io.datarouter.bytes.Codec<T,String>
    • decode

      public T decode(String encodedValue)
      Specified by:
      decode in interface io.datarouter.bytes.Codec<T,String>