Class PersistentDataType<T>

java.lang.Object
net.tnemc.item.persistent.PersistentDataType<T>
Direct Known Subclasses:
PersistentBool, PersistentByte, PersistentByteArray, PersistentDouble, PersistentFloat, PersistentInt, PersistentIntArray, PersistentLong, PersistentLongArray, PersistentShort, PersistentString

public abstract class PersistentDataType<T> extends Object
PersistentDataType
Since:
0.2.0.0
Author:
creatorfromhell
  • Constructor Details

  • Method Details

    • identifier

      public String identifier()
    • type

      public abstract String type()
      Returns the type of the PersistentDataType.
      Returns:
      The type of the PersistentDataType as a String.
      Since:
      0.2.0.0
    • encode

      public abstract String encode()
      Encodes the value of the PersistentDataType into a string representation.
      Returns:
      The encoded string representation of the value
      Since:
      0.2.0.0
    • decode

      public abstract T decode(String encoded) throws IllegalArgumentException
      Decodes the given encoded string and sets the decoded value.
      Parameters:
      encoded - The string to be decoded
      Returns:
      The decoded value of type T
      Throws:
      IllegalArgumentException - if the encoded string is invalid
      Since:
      0.2.0.0
    • readJSON

      public void readJSON(JSONHelper json)
      Decodes the JSON object and sets the values in the current instance.
      Parameters:
      json - The JSON object to be decoded
      Since:
      0.2.0.0
    • toJSON

      public org.json.simple.JSONObject toJSON()