Build the actual Trigger -- NOT intended to be invoked by end users, but
will rather be invoked by a TriggerBuilder which this ScheduleBuilder is
given to.

@see TriggerBuilder#withSchedule(IScheduleBuilder)
160890
@Override
  @Nonnull
  public SimpleTrigger build ()
  {
    final SimpleTrigger ret = new SimpleTrigger ();
    ret.setRepeatInterval (m_nInterval);
    ret.setRepeatCount (m_nRepeatCount);
    ret.setMisfireInstruction (m_nMisfireInstruction);
    return ret;
  }
917147
public function buildForm(FormBuilderInterface $builder, array $options): void
    {
        $schedule = $options['data'];
        $builder
            ->add('name', null, [
                'label' => 'schedule.form.name',
            ])
            ->add('location', null, [
                'label' => 'schedule.form.location',
            ])
            ->add('description', CKEditorType::class, [
                'label' => 'schedule.form.description',
                'config' => ['toolbar' => 'basic'],
                'required' => false, ])
            ->add('colour', ChoiceType::class, [
                'label' => 'schedule.form.colour',
                'required' => false,
                'choices' => [
                    'schedule.form.colour_choices.red' => 'important',
                    'schedule.form.colour_choices.green' => 'success',
                    'schedule.form.colour_choices.yellow' => 'warning',
                    'schedule.form.colour_choices.blue' => 'info',
                    'schedule.form.colour_choices.dark' => 'inverse',
                    'schedule.form.colour_choices.purple' => 'special',
                ],
            ])
            ->add('active', ChoiceType::class, [
                // Show "unpublished" instead of active.
                'choice_loader' => new CallbackChoiceLoader(function () use ($schedule) {
                    yield 'schedule.form.status_choices.active' => true;
                    if (!$schedule->isPublished()) {
                        yield 'schedule.form.status_choices.unpublished' => false;
                    } else {
                        yield 'schedule.form.status_choices.archived' => false;
                    }
                }),
                'label' => 'schedule.form.status',
            ])
            ->add('events', CollectionType::class, [
                'label' => 'schedule.form.events',
                'entry_type' => ScheduleEventType::class,
                'entry_options' => ['label' => false],
                'allow_add' => true,
                'allow_delete' => true,
                'by_reference' => false,
            ])
        ;
    }
1204414
protected void schedule() {
    try (LockResource r = new LockResource(mLock)) {
      Preconditions.checkState(!mScheduled, "Called schedule twice without waiting for any ticks");
      mScheduled = true;
      mTickCondition.signal();
      HeartbeatScheduler.removeTimer(this);
    }
  }
1358953
public function build()
    {
        if(null == $this->scheduleBuilder) {
            $this->scheduleBuilder = SimpleScheduleBuilder::simpleSchedule();
        }

        if (null == $this->startTime) {
            $this->startTime = new \DateTime();
        }

        $trigger = $this->scheduleBuilder->build();

        $trigger->setCalendarName($this->calendarName);
        $trigger->setDescription($this->description);
        $trigger->setStartTime($this->startTime);
        $trigger->setEndTime($this->endTime);

        if(null == $this->key) {
            $this->key = new Key(Key::createUniqueName(null), null);
        }

        $trigger->setKey($this->key);

        if($this->jobKey) {
            $trigger->setJobKey($this->jobKey);
        }

        $trigger->setPriority($this->priority);

        if($this->jobDataMap) {
            $trigger->setJobDataMap($this->jobDataMap);
        }

        return $trigger;
    }
841331
@Nonnull
  public CalendarIntervalTrigger build ()
  {
    final CalendarIntervalTrigger st = new CalendarIntervalTrigger ();
    st.setRepeatInterval (m_nInterval);
    st.setRepeatIntervalUnit (m_eIntervalUnit);
    st.setMisfireInstruction (m_nMisfireInstruction);
    st.setTimeZone (m_aTimeZone);
    st.setPreserveHourOfDayAcrossDaylightSavings (m_bPreserveHourOfDayAcrossDaylightSavings);
    st.setSkipDayIfHourDoesNotExist (m_bSkipDayIfHourDoesNotExist);
    return st;
  }
186169
@Nonnull
  public CronTrigger build ()
  {
    final CronTrigger ct = new CronTrigger ();
    ct.setCronExpression (m_aCronExpression);
    ct.setTimeZone (m_aCronExpression.getTimeZone ());
    ct.setMisfireInstruction (m_nMisfireInstruction);
    return ct;
  }
982673
private static Calendar buildCalendar() {

    Calendar calendar = calendarCache.get();
    if (calendar == null) {
      calendar = GregorianCalendar.getInstance();
      calendarCache.set(calendar);
    }
    return calendar;
  }
138073
private Trigger createTrigger(JobKey jobKey, JobSpec jobSpec) {
    // Build a trigger for the job with the given cron-style schedule
    return TriggerBuilder.newTrigger()
        .withIdentity("Cron for " + jobSpec.getUri())
        .forJob(jobKey)
        .withSchedule(CronScheduleBuilder.cronSchedule(
                         jobSpec.getConfig().getString(ConfigurationKeys.JOB_SCHEDULE_KEY)))
        .build();
  }
415160
public void triggerJob (final JobKey jobKey, final JobDataMap data) throws SchedulerException
  {
    m_aSched.triggerJob (jobKey, data);
  }
539252
public function build() {

        $trigger = new SimpleTrigger();
        $trigger->setRepeatInterval($this->interval);
        $trigger->setRepeatCount($this->repeatCount);
        $trigger->setMisfireInstruction($this->misfireInstruction);

        return $trigger;
    }
908140
@Override
    public Date nextExecutionTime(TriggerContext triggerContext) {
        if (triggerContext.lastScheduledExecutionTime() == null) {
            return new Date(System.currentTimeMillis() + this.initialDelay);
        } else if (this.fixedRate) {
            return new Date(triggerContext.lastScheduledExecutionTime().getTime() + this.period);
        }
        return new Date(triggerContext.lastCompletionTime().getTime() + this.period);
    }
645834
@Override
    @Transactional
    public synchronized void startAlertScheduling() {
        requireNotDisposed();
        if (_alertSchedulingThread != null && _alertSchedulingThread.isAlive()) {
            _logger.info("Request to start alert scheduling aborted as it is already running.");
        } else {
            _logger.info("Starting alert scheduling thread.");
            _alertSchedulingThread = new SchedulingThread("schedule-alerts", LockType.ALERT_SCHEDULING);
            _alertSchedulingThread.start();
            _logger.info("Alert scheduling thread started.");
        }
    }
475613
private Trigger getTrigger(JobKey jobKey, Properties jobProps) {
    // Build a trigger for the job with the given cron-style schedule
    return TriggerBuilder.newTrigger()
        .withIdentity(jobProps.getProperty(ConfigurationKeys.JOB_NAME_KEY),
            Strings.nullToEmpty(jobProps.getProperty(ConfigurationKeys.JOB_GROUP_KEY)))
        .forJob(jobKey)
        .withSchedule(CronScheduleBuilder.cronSchedule(jobProps.getProperty(ConfigurationKeys.JOB_SCHEDULE_KEY)))
        .build();
  }
857626
@Override
  public IScheduleBuilder <IDailyTimeIntervalTrigger> getScheduleBuilder ()
  {

    final DailyTimeIntervalScheduleBuilder cb = DailyTimeIntervalScheduleBuilder.dailyTimeIntervalSchedule ()
                                                                                .withInterval (getRepeatInterval (),
                                                                                               getRepeatIntervalUnit ())
                                                                                .onDaysOfTheWeek (getDaysOfWeek ())
                                                                                .startingDailyAt (getStartTimeOfDay ())
                                                                                .endingDailyAt (getEndTimeOfDay ());

    switch (getMisfireInstruction ())
    {
      case MISFIRE_INSTRUCTION_DO_NOTHING:
        cb.withMisfireHandlingInstructionDoNothing ();
        break;
      case MISFIRE_INSTRUCTION_FIRE_ONCE_NOW:
        cb.withMisfireHandlingInstructionFireAndProceed ();
        break;
    }

    return cb;
  }
573729
@Override
    public void run() {
        Date actualExecutionTime = new Date();
        super.run();
        Date completionTime = new Date();
        synchronized (this.triggerContextMonitor) {
            this.triggerContext.update(this.scheduledExecutionTime, actualExecutionTime, completionTime);
            if (!this.currentFuture.isCancelled()) {
                schedule();
            }
        }
    }
499918
@Inject
    public void schedule( Scheduler scheduler )
        throws Exception
    {
        if ( cronExpression == null && trigger == null )
        {
            throw new ProvisionException( format( "Impossible to schedule Job '%s' without cron expression",
                                                  jobClass.getName() ) );
        }
        if ( cronExpression != null && trigger != null )
        {
          throw new ProvisionException( format( "Impossible to schedule Job '%s' with cron expression " +
                                                "and an associated Trigger at the same time", jobClass.getName() ) );
        }

        JobKey jobKey = jobKey( DEFAULT.equals( jobName ) ? jobClass.getName() : jobName, jobGroup );
        TriggerKey triggerKey = triggerKey( DEFAULT.equals( triggerName ) ? jobClass.getCanonicalName() : triggerName, triggerGroup );

        if ( updateExistingTrigger && scheduler.checkExists( triggerKey ) ) {
            scheduler.unscheduleJob( triggerKey );
        }

        scheduler.scheduleJob( newJob( jobClass )
                               .withIdentity( jobKey )
                               .requestRecovery( requestRecovery )
                               .storeDurably( storeDurably ).build(),
                               ( trigger == null ) ?
                               newTrigger()
                               .withIdentity( triggerKey )
                               .withSchedule( cronSchedule( cronExpression )
                                              .inTimeZone( timeZone ) )
                                              .withPriority( priority )
                                              .build()
                                : trigger);
    }
1263452
public static CronTriggerBuilder cronTriggerBuilder(String cronExpression) throws ParseException {

    CronExpression.validateExpression(cronExpression);
    return new CronTriggerBuilder(cronExpression);
  }