Interface EventConverter<E extends Event>

All Known Implementing Classes:
AllocateEventConverter, SubstituteVMEventConverter

public interface EventConverter<E extends Event>
Specify a JSON converter for a Event.
Author:
Fabien Hermenier
  • Method Summary

    Modifier and Type Method Description
    void fillJSON​(E ev, net.minidev.json.JSONObject ob)  
    E fromJSON​(Model mo, net.minidev.json.JSONObject ob)
    Create an event from a JSON Object.
    String id()
    The JSON identifier for the event.
    Class<E> supportedEvent()
    The action that is supported by this converter.
    default net.minidev.json.JSONObject toJSON​(E ev)
    Create a JSON from an event.
  • Method Details

    • id

      String id()
      The JSON identifier for the event.
      Returns:
      a String that will be written inside the field ActionConverter.ID_LABEL
    • supportedEvent

      Class<E> supportedEvent()
      The action that is supported by this converter.
      Returns:
      the event class.
    • fillJSON

      void fillJSON​(E ev, net.minidev.json.JSONObject ob)
    • fromJSON

      E fromJSON​(Model mo, net.minidev.json.JSONObject ob) throws JSONConverterException
      Create an event from a JSON Object.
      Parameters:
      mo - the model to use to parse elements.
      ob - the object to convert
      Returns:
      the resulting event.
      Throws:
      JSONConverterException - if the conversion failed.
    • toJSON

      default net.minidev.json.JSONObject toJSON​(E ev)
      Create a JSON from an event. First, a skeleton is created to mention the event identifier, Second, fillJSON(E, net.minidev.json.JSONObject) is called.
      Parameters:
      ev - the event to convert.
      Returns:
      the resulting JSON message.