/** * Retrieves the routing keys of every command handler on the given {@code childEntityModel} to be able to correctly * route commands to Entities. * * @param field a {@link java.lang.reflect.Field} denoting the Child Entity upon which the {@code * childEntityModel} is based. * @param childEntityModel a {@link EntityModel} to retrieve the * routing key properties from. * @return a {@link java.util.Map} of key/value types {@link java.lang.String}/ * {@link org.axonframework.common.property.Property} from Command Message name to routing key. */ @SuppressWarnings("WeakerAccess") protected Map<String, Property<Object>> extractCommandHandlerRoutingKeys(Field field, EntityModel<Object> childEntityModel) { return childEntityModel.commandHandlers() .stream() .map(commandHandler -> commandHandler.unwrap(CommandMessageHandlingMember.class) .orElse(null)) .filter(Objects::nonNull) .collect(Collectors.toMap( CommandMessageHandlingMember::commandName, commandHandler -> extractCommandHandlerRoutingKey(childEntityModel, commandHandler, field ) )); }
/** * Retrieves the routing keys of every command handler on the given {@code childEntityModel} to be able to correctly * route commands to Entities. * * @param field a {@link java.lang.reflect.Field} denoting the Child Entity upon which the {@code * childEntityModel} is based. * @param childEntityModel a {@link EntityModel} to retrieve the * routing key properties from. * @return a {@link java.util.Map} of key/value types {@link java.lang.String}/ * {@link org.axonframework.common.property.Property} from Command Message name to routing key. */ @SuppressWarnings("WeakerAccess") protected Map<String, Property<Object>> extractCommandHandlerRoutingKeys(Field field, EntityModel<Object> childEntityModel) { return childEntityModel.commandHandlers() .stream() .map(commandHandler -> commandHandler.unwrap(CommandMessageHandlingMember.class) .orElse(null)) .filter(Objects::nonNull) .collect(Collectors.toMap( CommandMessageHandlingMember::commandName, commandHandler -> extractCommandHandlerRoutingKey(childEntityModel, commandHandler, field ) )); }