class OpenHoursServiceImpl implements OpenHoursService {

    @Override
    public OpeningHours save(OpeningHours hours) {
        log.info(LogMessage.IN_SAVE);

        if (hours.getOpenTime().getHour() > hours.getCloseTime().getHour()) {
            throw new BadRequestException(ErrorMessage.CLOSE_TIME_LATE_THAN_OPEN_TIME);
        }

        if (hours.getBreakTime() != null) {
            if (hours.getBreakTime().getStartTime().getHour() > hours.getOpenTime().getHour()
                && hours.getBreakTime().getEndTime().getHour() < hours.getCloseTime().getHour()) {
                breakTimeService.save(hours.getBreakTime());
            } else {
                throw new BadRequestException(ErrorMessage.WRONG_BREAK_TIME);
            }
        }
        return hoursRepo.save(hours);
    }

}