org.axonframework.domain
Class EventBase

java.lang.Object
  extended by org.axonframework.domain.EventBase
All Implemented Interfaces:
Serializable, Event
Direct Known Subclasses:
ApplicationEvent, DomainEvent

public abstract class EventBase
extends Object
implements Event

Base class for all types of events. Contains the event identifier and timestamp.

Since:
0.4
Author:
Allard Buijze
See Also:
Serialized Form

Constructor Summary
protected EventBase()
          Initialize a new event.
 
Method Summary
protected  void addMetaData(String key, Serializable value)
          Insert a key-value pair into the meta data of this event.
 boolean equals(Object o)
          Checks the equality of two events.
 UUID getEventIdentifier()
          Returns the identifier of this event.
 long getEventRevision()
          Returns the revision number of this event definition.
 EventMetaData getMetaData()
          Returns the meta data for this event.
 Serializable getMetaDataValue(String key)
          Returns the value registered in the meta data under the given key.
 org.joda.time.LocalDateTime getTimestamp()
          Returns the timestamp of this event.
 int hashCode()
          
protected  void setEventRevision(long eventRevision)
          Sets the revision of the implementing event definition.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EventBase

protected EventBase()
Initialize a new event. This constructor will set the event identifier to a random UUID and the timestamp to the current date and time.

Method Detail

getEventIdentifier

public UUID getEventIdentifier()
Returns the identifier of this event.

Specified by:
getEventIdentifier in interface Event
Returns:
the identifier of this event.

addMetaData

protected final void addMetaData(String key,
                                 Serializable value)
Insert a key-value pair into the meta data of this event. If a value already exists for the given key, it is overwritten with the value provided.

Note: this method should *never* be called after an event has been dispatched or stored.

Be careful when using key values with the underscore ( _ ) prefix. They might collide with internal Axon meta data.

Parameters:
key - The key of the key-value pair
value - The value to store in the meta data

getTimestamp

public org.joda.time.LocalDateTime getTimestamp()
Returns the timestamp of this event. The timestamp is set to the date and time the event was created.

Specified by:
getTimestamp in interface Event
Returns:
the timestamp of this event.

getMetaData

public EventMetaData getMetaData()
Returns the meta data for this event. This meta data is a collection of key-value pairs, where the key is a String, and the value is a serializable object.

Specified by:
getMetaData in interface Event
Returns:
the meta data for this event

getMetaDataValue

public Serializable getMetaDataValue(String key)
Returns the value registered in the meta data under the given key. If no value is known for the given key, this method returns null.

Specified by:
getMetaDataValue in interface Event
Parameters:
key - The key of the meta data entry
Returns:
The value registered under the given key, or null if the key wasn't found

equals

public boolean equals(Object o)
Checks the equality of two events. Events are equal if they have the same type and identifier.

Overrides:
equals in class Object
Parameters:
o - the object to compare this event to
Returns:
true if o is equal to this event instance

hashCode

public int hashCode()

Overrides:
hashCode in class Object

setEventRevision

protected void setEventRevision(long eventRevision)
Sets the revision of the implementing event definition. Revision numbers are use by UpCasters to decide which transformations to apply when deserializing an event. Revision numbers only need to be supplied if the structure has been changed in such a way that the event serializer cannot deserialize it without help from an UpCaster.

Parameters:
eventRevision - The revision of the event definition

getEventRevision

public long getEventRevision()
Returns the revision number of this event definition.

Returns:
the revision number of this event definition


Copyright © 2011. All Rights Reserved.