Package com.bank.trading
Class Event
java.lang.Object
com.bank.trading.Event
Object used system-wide to represent an event.
All events go through the Lamport clock to be timestamped.
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionEvent(byte[] binary) Constructor for an event with a timestamp.Event(Event.Type type, String message) Constructor for an event. -
Method Summary
Modifier and TypeMethodDescriptionbyte[]Get the binary data for the event.Returns the message associated with the event.getOrder()Returns the order associated with the event.Get the ticker associated with the event.Returns the timestamp of the event.getType()Returns the type of the event.voidsetBinaryData(byte[] data) Set the binary data for the event.voidSets the order associated with the event.voidSet the ticker associated with the event.voidsetTimestamp(Long timestamp) Sets the timestamp of the event.byte[]toBinary()Convert the event to a binary format.
-
Constructor Details
-
Event
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
Returns the type of the event.- Returns:
- the type of the event.
-
getMessage
Returns the message associated with the event.- Returns:
- the message of the event.
-
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
Sets the timestamp of the event. This should only be set by the Lamport clock.- Parameters:
timestamp- the timestamp of the event.
-
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
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
Get the ticker associated with the event.- Returns:
- the ticker associated with the event.
-
setTicker
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.
-