Class TransactionAdapter

java.lang.Object
edu.ntnu.idi.idatt.storage.util.TransactionAdapter
All Implemented Interfaces:
com.google.gson.JsonDeserializer<Transaction>, com.google.gson.JsonSerializer<Transaction>

public class TransactionAdapter extends Object implements com.google.gson.JsonSerializer<Transaction>, com.google.gson.JsonDeserializer<Transaction>
Transaction adapter class.

Guides Gson serializer/deserializer how to handle abstract object types.

  • Constructor Details

    • TransactionAdapter

      public TransactionAdapter()
  • Method Details

    • serialize

      public com.google.gson.JsonElement serialize(Transaction t, Type typeOfT, com.google.gson.JsonSerializationContext context)
      Method for serialization of Transactions.
      Specified by:
      serialize in interface com.google.gson.JsonSerializer<Transaction>
      Parameters:
      t - - Current transaction.
      typeOfT - - Type of transaction.
      context - - Serialization information.
    • deserialize

      public Transaction deserialize(com.google.gson.JsonElement json, Type typeOfT, com.google.gson.JsonDeserializationContext context) throws com.google.gson.JsonParseException
      Method for deserialization of Transactions.
      Specified by:
      deserialize in interface com.google.gson.JsonDeserializer<Transaction>
      Parameters:
      json - - Current transaction json text.
      typeOfT - - type of transaction.
      context - - Deserialization information.
      Throws:
      com.google.gson.JsonParseException