Class GSON

java.lang.Object
it.polimi.ingsw.utility.GSON

public final class GSON
extends java.lang.Object
Contains all the possible method used to parse to and from a json string. Can be used for loading configuration files or for sending and receiving messages to and from the network
  • Method Summary

    Modifier and Type Method Description
    static Action buildAction​(java.lang.String payload)
    constructs an ACTION from the given JSON payload
    static DevelopCardDeck cardParser()
    construct and setup a DevelopCardDeck class from a JSON config file
    static com.google.gson.Gson getGsonBuilder()
    Static method to obtain a GsonBuilder with the necessary modifiers enebled
    static LeaderCardDeck leaderCardParser()
    construct and setup LeaderCardDeck class from a JSON config file
    static LorenzoTrack lorenzoTrackParser()
    construct LorenzoTrack class from a JSON config file
    static Track trackParser()
    construct track class from a JSON config file

    Methods inherited from class java.lang.Object

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

    • getGsonBuilder

      public static com.google.gson.Gson getGsonBuilder()
      Static method to obtain a GsonBuilder with the necessary modifiers enebled
      Returns:
      the gsonBuilder
    • cardParser

      public static DevelopCardDeck cardParser() throws java.io.IOException
      construct and setup a DevelopCardDeck class from a JSON config file
      Returns:
      the constructed DevelopCardDeck
      Throws:
      java.io.IOException - if it is unable to read the configuration file
    • trackParser

      public static Track trackParser() throws java.io.IOException
      construct track class from a JSON config file
      Returns:
      the constructed Track
      Throws:
      java.io.IOException - if it is unable to read the configuration file
    • lorenzoTrackParser

      public static LorenzoTrack lorenzoTrackParser() throws java.io.IOException
      construct LorenzoTrack class from a JSON config file
      Returns:
      the constructed LorenzoTrack
      Throws:
      java.io.IOException - if it is unable to read the configuration file
    • leaderCardParser

      public static LeaderCardDeck leaderCardParser() throws java.io.IOException
      construct and setup LeaderCardDeck class from a JSON config file
      Returns:
      the constructed LeaderCardDeck
      Throws:
      java.io.IOException - if it is unable to read the configuration file
    • buildAction

      public static Action buildAction​(java.lang.String payload)
      constructs an ACTION from the given JSON payload
      Parameters:
      payload - JSON representation of the ACTION to be constructed
      Returns:
      the newly created action