package at.procon.eventhub.camel;

import at.procon.eventhub.dto.EventHubEventDto;
import at.procon.eventhub.service.EventHubEventValidator;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.springframework.stereotype.Component;

@Component
public class EventHubEventValidationProcessor implements Processor {

    private final EventHubEventValidator validator;

    public EventHubEventValidationProcessor(EventHubEventValidator validator) {
        this.validator = validator;
    }

    @Override
    public void process(Exchange exchange) {
        EventHubEventDto event = exchange.getMessage().getBody(EventHubEventDto.class);
        validator.validate(event);
    }
}
