public class EventFactory
extends java.lang.Object
Modifier | Constructor and Description |
---|---|
protected |
EventFactory(EventOrigin origin,
com.google.protobuf.Any producerId) |
Modifier and Type | Method and Description |
---|---|
io.spine.core.Event |
createEvent(io.spine.base.EventMessage message,
@Nullable io.spine.core.Version version)
Creates an event for the passed event message.
|
io.spine.core.Event |
createRejectionEvent(io.spine.base.RejectionMessage message,
@Nullable io.spine.core.Version version,
io.spine.core.RejectionEventContext rejectionContext)
Creates a rejection event for the passed rejection message.
|
static EventFactory |
forImport(io.spine.core.ActorContext actorContext,
com.google.protobuf.Any producerId)
Creates a new event factory for producing events to be imported into a Bounded Context.
|
static EventFactory |
on(MessageEnvelope origin,
com.google.protobuf.Any producerId)
Creates a new event factory for producing events in response to the passed message.
|
protected EventFactory(EventOrigin origin, com.google.protobuf.Any producerId)
public static EventFactory on(MessageEnvelope origin, com.google.protobuf.Any producerId)
origin
- the message in response to which events will be generatedproducerId
- the ID of the entity producing the eventspublic static EventFactory forImport(io.spine.core.ActorContext actorContext, com.google.protobuf.Any producerId)
actorContext
- the description of the actor who imports the eventsproducerId
- the ID of the system which produced the eventspublic io.spine.core.Event createEvent(io.spine.base.EventMessage message, @Nullable io.spine.core.Version version) throws io.spine.validate.ValidationException
The message passed is validated according to the constraints set in its Protobuf definition. If the message is invalid, an exception is thrown.
In the message is an instance of Any
, it is unpacked for validation.
message
- the message of the eventversion
- the version of the entity which produces the eventio.spine.validate.ValidationException
- if the passed message does not satisfy the constraints
set for it in its Protobuf definitionpublic io.spine.core.Event createRejectionEvent(io.spine.base.RejectionMessage message, @Nullable io.spine.core.Version version, io.spine.core.RejectionEventContext rejectionContext) throws io.spine.validate.ValidationException
message
- the rejection messageversion
- the version of the event to createrejectionContext
- the rejection contextio.spine.validate.ValidationException
- if the passed message does not satisfy the constraints
set for it in its Protobuf definitioncreateEvent(Message, Version) - for general rules of the event
construction