Class DistanceAdapter

java.lang.Object
com.google.gson.TypeAdapter<Distance>
ai.nextbillion.maps.internal.DistanceAdapter

public class DistanceAdapter
extends com.google.gson.TypeAdapter<Distance>
This class handles conversion from JSON to Distance.

Please see GSON Type Adapter for more detail.

  • Constructor Summary

    Constructors 
    Constructor Description
    DistanceAdapter()  
  • Method Summary

    Modifier and Type Method Description
    Distance read​(com.google.gson.stream.JsonReader reader)
    Read a distance object from a Directions API result and convert it to a Distance.
    void write​(com.google.gson.stream.JsonWriter writer, Distance value)
    This method is not implemented.

    Methods inherited from class com.google.gson.TypeAdapter

    fromJson, fromJson, fromJsonTree, nullSafe, toJson, toJson, toJsonTree

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • read

      public Distance read​(com.google.gson.stream.JsonReader reader) throws java.io.IOException
      Read a distance object from a Directions API result and convert it to a Distance.

      We are expecting to receive something akin to the following:

       {
         "value": 207, "text": "0.1 mi"
       }
       
      Specified by:
      read in class com.google.gson.TypeAdapter<Distance>
      Throws:
      java.io.IOException
    • write

      public void write​(com.google.gson.stream.JsonWriter writer, Distance value) throws java.io.IOException
      This method is not implemented.
      Specified by:
      write in class com.google.gson.TypeAdapter<Distance>
      Throws:
      java.io.IOException