public final class CommandFactory
extends java.lang.Object
Command
instances.
Uses the given ActorRequestFactory
as a source of command meta information
such as the actor, the tenant, and others.
The command messages passed to the factory are
validated
according to their Proto definitions. If a given message is invalid,
a ValidationException
is thrown.
ActorRequestFactory.command()
Modifier and Type | Method and Description |
---|---|
io.spine.core.Command |
create(io.spine.base.CommandMessage message)
Creates a new
Command with the given message. |
io.spine.core.Command |
create(io.spine.base.CommandMessage message,
int targetVersion)
Creates a new
Command with the passed message and target entity version. |
public io.spine.core.Command create(io.spine.base.CommandMessage message) throws io.spine.validate.ValidationException
Command
with the given message.message
- the command messageio.spine.validate.ValidationException
- if the passed message does not satisfy the constraints,
set for it in its Protobuf definitionpublic io.spine.core.Command create(io.spine.base.CommandMessage message, int targetVersion) throws io.spine.validate.ValidationException
Command
with the passed message and target entity version.
The targetVersion
parameter defines the version of the entity which handles
the resulting command. Note that the framework performs no validation of the target version
before a command is handled. Instead users themselves can perform validation.
message
- the command messagetargetVersion
- the version of the entity for which this command is intendedio.spine.validate.ValidationException
- if the passed message does not satisfy the constraints
set for it in its Protobuf definition