org.springframework.scheduling.support

## 类 PeriodicTrigger

- java.lang.Object
- - org.springframework.scheduling.support.PeriodicTrigger

- 所有已实现的接口:
    Trigger

      public class PeriodicTrigger
      extends Object
      implements Trigger

  A trigger for periodic task execution. The period may be applied as either fixed-rate or fixed-delay, and an initial delay value may also be configured. The default initial delay is 0, and the default behavior is fixed-delay (i.e. the interval between successive executions is measured from each completion time). To measure the interval between the scheduled start time of each execution instead, set the 'fixedRate' property to `true`.

  Note that the TaskScheduler interface already defines methods for scheduling tasks at fixed-rate or with fixed-delay. Both also support an optional value for the initial delay. Those methods should be used directly whenever possible. The value of this Trigger implementation is that it can be used within components that rely on the Trigger abstraction. For example, it may be convenient to allow periodic triggers, cron-based triggers, and even custom Trigger implementations to be used interchangeably.

  从以下版本开始:
    3.0
  作者:
    Mark Fisher

- - ### 构造器概要

    构造器
    构造器和说明
    `PeriodicTrigger(long period)` Create a trigger with the given period in milliseconds.
    `PeriodicTrigger(long period, TimeUnit timeUnit)` Create a trigger with the given period and time unit.

  - ### 方法概要

    所有方法 实例方法 具体方法
    限定符和类型 | 方法和说明
    --- | ---
    `boolean` | `equals(Object other)`
    `long` | `getInitialDelay()` Return the initial delay, or 0 if none.
    `long` | `getPeriod()` Return this trigger's period.
    `TimeUnit` | `getTimeUnit()` Return this trigger's time unit (milliseconds by default).
    `int` | `hashCode()`
    `boolean` | `isFixedRate()` Return whether this trigger uses fixed rate (`true`) or fixed delay (`false`) behavior.
    `Date` | `nextExecutionTime(TriggerContext triggerContext)` Returns the time after which a task should run again.
    `void` | `setFixedRate(boolean fixedRate)` Specify whether the periodic interval should be measured between the scheduled start times rather than between actual completion times.
    `void` | `setInitialDelay(long initialDelay)` Specify the delay for the initial execution.

    - ### 从类继承的方法 java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

- - ### 构造器详细资料

    - #### PeriodicTrigger

          public PeriodicTrigger(long period)

      Create a trigger with the given period in milliseconds.

    - #### PeriodicTrigger

          public PeriodicTrigger(long period,
                                 @Nullable
                                 TimeUnit timeUnit)

      Create a trigger with the given period and time unit. The time unit will apply not only to the period but also to any 'initialDelay' value, if configured on this Trigger later via `setInitialDelay(long)`.

  - ### 方法详细资料

    - #### getPeriod

          public long getPeriod()

      Return this trigger's period.
      从以下版本开始:
        5.0.2

    - #### getTimeUnit

          public TimeUnit getTimeUnit()

      Return this trigger's time unit (milliseconds by default).
      从以下版本开始:
        5.0.2

    - #### setInitialDelay

          public void setInitialDelay(long initialDelay)

      Specify the delay for the initial execution. It will be evaluated in terms of this trigger's `TimeUnit`. If no time unit was explicitly provided upon instantiation, the default is milliseconds.

    - #### getInitialDelay

          public long getInitialDelay()

      Return the initial delay, or 0 if none.
      从以下版本开始:
        5.0.2

    - #### setFixedRate

          public void setFixedRate(boolean fixedRate)

      Specify whether the periodic interval should be measured between the scheduled start times rather than between actual completion times. The latter, "fixed delay" behavior, is the default.

    - #### isFixedRate

          public boolean isFixedRate()

      Return whether this trigger uses fixed rate (`true`) or fixed delay (`false`) behavior.
      从以下版本开始:
        5.0.2

    - #### nextExecutionTime

          public Date nextExecutionTime(TriggerContext triggerContext)

      Returns the time after which a task should run again.
      指定者:
        `nextExecutionTime` 在接口中 `Trigger`
      参数:
        `triggerContext` - context object encapsulating last execution times and last completion time
      返回:
        the next execution time as defined by the trigger, or `null` if the trigger won't fire anymore

    - #### equals

          public boolean equals(Object other)

      覆盖:
        `equals` 在类中 `Object`

    - #### hashCode

          public int hashCode()

      覆盖:
        `hashCode` 在类中 `Object`