public CommandType getCommandType() { return CommandType.of(aggregateType, commandName); }
public static CommandMethodMapping forMethod(Method method, String aggregateType) { checkNotNull(method, "method must not be null"); final VersionedName commandName = getCommandName(method); ParameterArgs parameterArgs = ParameterArgs.forMethod(method, 2); TupleSchema schema = parameterArgs.getTupleSchema(CommandType.of(aggregateType, commandName).toString()); TupleKey[] tupleKeys = parameterArgs.getTupleKeys(schema); return new CommandMethodMapping( aggregateType, commandName, schema, tupleKeys, method.getGenericReturnType()); }
/** * Convert this {@link CommandJson} to an {@link Command}, using the supplied {@link CommandTypeMatcher} and * {@link ObjectMapper}. * @param typeMatcher The {@link CommandTypeMatcher} to use to resolve {@link CommandType}s to * {@link com.opencredo.concursus.domain.commands.CommandTypeInfo}. * @param objectMapper The {@link ObjectMapper} to use to deserialise event parameters. * @return The converted {@link Command}, iff the {@link CommandTypeMatcher} matches its type. */ public Optional<Command> toCommand(CommandTypeMatcher typeMatcher, ObjectMapper objectMapper) { CommandType commandType = getCommandType(); BiFunction<JsonNode, Type, Object> deserialiser = makeDeserialiser(objectMapper); return typeMatcher.match(commandType).map(typeInfo -> commandType.makeCommand( aggregateId, StreamTimestamp.of(streamId, Instant.ofEpochMilli(commandTimestamp)), typeInfo.getTupleSchema().deserialise(deserialiser, parameters), typeInfo.getReturnType() )) .map(command -> processingId.isEmpty() ? command : command.processed(UUID.fromString(processingId)) ); }
@JsonIgnore public CommandType getCommandType() { return CommandType.of(aggregateType, VersionedName.of(name, version)); } }