class RepositoryUserAccessService implements UserAccessService {

    @Override
    public boolean userHasActiveAccessInterval(User user) {
        var latestIntervalOptional = user.getLatestAccessInterval();

        if(latestIntervalOptional.isPresent()) {
            var latestInterval = latestIntervalOptional.get();

            var startTime = latestInterval.getStartTime();
            var endTime = latestInterval.getEndTime();
            var now = LocalDateTime.now(clock);

            return (startTime.isEqual(now) || startTime.isBefore(now)) && (endTime.isEqual(now) || endTime.isAfter(now));
        }

        return false;
    }

    @Autowired public  RepositoryUserAccessService(RepositoryUserService userService,
                                       AccessIntervalRepository intervalRepo,
                                       UserAccessEventHandler userAccessEventHandler,
                                       Clock clock);

}