SchedulerConfig extends Config { void validateJob(String name, Job job) { Class<? extends Job> jobClass = job.getClass(); if (jobClass.isSynthetic()) throw new Error(Strings.format("job class must not be anonymous class or lambda, please create static class, name={}, jobClass={}", name, jobClass.getCanonicalName())); new InjectValidator(job).validate(); }  void timeZone(ZoneId zoneId); void fixedRate(String name, Job job, Duration rate); void hourlyAt(String name, Job job, int minute, int second); void dailyAt(String name, Job job, LocalTime time); void weeklyAt(String name, Job job, DayOfWeek dayOfWeek, LocalTime time); void monthlyAt(String name, Job job, int dayOfMonth, LocalTime time); void trigger(String name, Job job, Trigger trigger);  }
@Test void validateJob() { assertThatThrownBy(() -> config.validateJob("job", context -> { })).isInstanceOf(Error.class) .hasMessageContaining("job class must not be anonymous class or lambda"); }