public void schedule(ExecutableMethod<?, ?> method) {
        if (hasParametersOutsideOfJobContext(method.getTargetMethod())) {
            throw new IllegalStateException("Methods annotated with " + Recurring.class.getName() + " can only have zero parameters or a single parameter of type JobContext.");
        }

        String id = getId(method);
        String cron = getCron(method);
        String interval = getInterval(method);

        if (StringUtils.isNullOrEmpty(cron) && StringUtils.isNullOrEmpty(interval))
            throw new IllegalArgumentException("Either cron or interval attribute is required.");
        if (isNotNullOrEmpty(cron) && isNotNullOrEmpty(interval))
            throw new IllegalArgumentException("Both cron and interval attribute provided. Only one is allowed.");

        if (Recurring.RECURRING_JOB_DISABLED.equals(cron) || Recurring.RECURRING_JOB_DISABLED.equals(interval)) {
            if (id == null) {
                LOGGER.warn("You are trying to disable a recurring job using placeholders but did not define an id.");
            } else {
                jobScheduler.deleteRecurringJob(id);
            }
        } else {
            JobDetails jobDetails = getJobDetails(method);
            ZoneId zoneId = getZoneId(method);

            if (isNotNullOrEmpty(cron)) {
                jobScheduler.scheduleRecurrently(id, jobDetails, CronExpression.create(cron), zoneId);
            } else {
                jobScheduler.scheduleRecurrently(id, jobDetails, new Interval(interval), zoneId);
            }
        }
    }
@Test
    void beansWithMethodsAnnotatedWithDisabledRecurringIntervalAnnotationWillAutomaticallyBeDeleted() {
        final ExecutableMethod executableMethod = mock(ExecutableMethod.class);
        final Method method = getRequiredMethod(MyServiceWithRecurringJob.class, "myRecurringMethod");
        when(executableMethod.getTargetMethod()).thenReturn(method);

        when(executableMethod.stringValue(Recurring.class, "id")).thenReturn(Optional.of("my-recurring-job"));
        when(executableMethod.stringValue(Recurring.class, "cron")).thenReturn(Optional.empty());
        when(executableMethod.stringValue(Recurring.class, "interval")).thenReturn(Optional.of("-"));

        jobRunrRecurringJobScheduler.schedule(executableMethod);

        verify(jobScheduler).deleteRecurringJob("my-recurring-job");
    }