Class Event

java.lang.Object
com.bank.trading.Event

public class Event extends Object
Object used system-wide to represent an event. All events go through the Lamport clock to be timestamped.
  • Constructor Details

    • Event

      public Event(Event.Type type, String message)
      Constructor for an event.
      Parameters:
      type - The type of the event.
      message - The message associated with the event.
    • Event

      public Event(byte[] binary)
      Constructor for an event with a timestamp. Used for constructing events from the Lamport clock or over the network.
      Parameters:
      binary - The binary data to make the event.
  • Method Details

    • getType

      public Event.Type getType()
      Returns the type of the event.
      Returns:
      the type of the event.
    • getMessage

      public String getMessage()
      Returns the message associated with the event.
      Returns:
      the message of the event.
    • getTimestamp

      public Long getTimestamp()
      Returns the timestamp of the event. This is set by the Lamport clock when the event is created.
      Returns:
      the timestamp of the event.
    • setTimestamp

      public void setTimestamp(Long timestamp)
      Sets the timestamp of the event. This should only be set by the Lamport clock.
      Parameters:
      timestamp - the timestamp of the event.
    • getOrder

      public Order getOrder()
      Returns the order associated with the event. This is only set for ORDER events.
      Returns:
      the order associated with the event, or null if not an ORDER event.
    • setOrder

      public void setOrder(Order order)
      Sets the order associated with the event. This should only be set for ORDER events.
      Parameters:
      order - the order to associate with the event.
    • setBinaryData

      public void setBinaryData(byte[] data)
      Set the binary data for the event.
      Parameters:
      data -
    • getTicker

      public String getTicker()
      Get the ticker associated with the event.
      Returns:
      the ticker associated with the event.
    • setTicker

      public void setTicker(String ticker)
      Set the ticker associated with the event.
      Parameters:
      ticker - the ticker to associate with the event.
    • getBinaryData

      public byte[] getBinaryData()
      Get the binary data for the event.
      Returns:
      the binary data for the event.
    • toBinary

      public byte[] toBinary()
      Convert the event to a binary format. This is used for sending the event over the network.
      Returns:
      the binary representation of the event.