• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

TAKETODAY / today-infrastructure / 18154768944

01 Oct 2025 07:26AM UTC coverage: 81.882% (-0.005%) from 81.887%
18154768944

push

github

web-flow
Merge pull request #290 from TAKETODAY/dev/jspecify

jspecify

59788 of 78013 branches covered (76.64%)

Branch coverage included in aggregate %.

141239 of 167496 relevant lines covered (84.32%)

3.6 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

94.74
today-context/src/main/java/infra/scheduling/support/SimpleTriggerContext.java
1
/*
2
 * Copyright 2017 - 2025 the original author or authors.
3
 *
4
 * This program is free software: you can redistribute it and/or modify
5
 * it under the terms of the GNU General Public License as published by
6
 * the Free Software Foundation, either version 3 of the License, or
7
 * (at your option) any later version.
8
 *
9
 * This program is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 * GNU General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU General Public License
15
 * along with this program. If not, see [https://www.gnu.org/licenses/]
16
 */
17

18
package infra.scheduling.support;
19

20
import org.jspecify.annotations.Nullable;
21

22
import java.time.Clock;
23
import java.time.Instant;
24

25
import infra.scheduling.TriggerContext;
26

27
/**
28
 * Simple data holder implementation of the {@link TriggerContext} interface.
29
 *
30
 * @author Juergen Hoeller
31
 * @author <a href="https://github.com/TAKETODAY">Harry Yang</a>
32
 * @since 4.0
33
 */
34
public class SimpleTriggerContext implements TriggerContext {
35

36
  private final Clock clock;
37

38
  @Nullable
39
  private volatile Instant lastScheduledExecution;
40

41
  @Nullable
42
  private volatile Instant lastActualExecution;
43

44
  @Nullable
45
  private volatile Instant lastCompletion;
46

47
  /**
48
   * Create a SimpleTriggerContext with all time values set to {@code null},
49
   * exposing the system clock for the default time zone.
50
   */
51
  public SimpleTriggerContext() {
2✔
52
    this.clock = Clock.systemDefaultZone();
3✔
53
  }
1✔
54

55
  /**
56
   * Create a SimpleTriggerContext with all time values set to {@code null},
57
   * exposing the given clock.
58
   *
59
   * @param clock the clock to use for trigger calculation
60
   * @see #update(Instant, Instant, Instant)
61
   */
62
  public SimpleTriggerContext(Clock clock) {
2✔
63
    this.clock = clock;
3✔
64
  }
1✔
65

66
  /**
67
   * Create a SimpleTriggerContext with the given time values,
68
   * exposing the system clock for the default time zone.
69
   *
70
   * @param lastScheduledExecution last <i>scheduled</i> execution time
71
   * @param lastActualExecution last <i>actual</i> execution time
72
   * @param lastCompletion last completion time
73
   */
74
  public SimpleTriggerContext(@Nullable Instant lastScheduledExecution,
75
          @Nullable Instant lastActualExecution, @Nullable Instant lastCompletion) {
76

77
    this();
2✔
78
    this.lastScheduledExecution = lastScheduledExecution;
3✔
79
    this.lastActualExecution = lastActualExecution;
3✔
80
    this.lastCompletion = lastCompletion;
3✔
81
  }
1✔
82

83
  /**
84
   * Update this holder's state with the latest time values.
85
   *
86
   * @param lastScheduledExecution last <i>scheduled</i> execution time
87
   * @param lastActualExecution last <i>actual</i> execution time
88
   * @param lastCompletion last completion time
89
   */
90
  public void update(@Nullable Instant lastScheduledExecution,
91
          @Nullable Instant lastActualExecution, @Nullable Instant lastCompletion) {
92

93
    this.lastScheduledExecution = lastScheduledExecution;
3✔
94
    this.lastActualExecution = lastActualExecution;
3✔
95
    this.lastCompletion = lastCompletion;
3✔
96
  }
1✔
97

98
  @Override
99
  public Clock getClock() {
100
    return this.clock;
3✔
101
  }
102

103
  @Override
104
  @Nullable
105
  public Instant lastScheduledExecution() {
106
    return this.lastScheduledExecution;
3✔
107
  }
108

109
  @Override
110
  @Nullable
111
  public Instant lastActualExecution() {
112
    return this.lastActualExecution;
×
113
  }
114

115
  @Override
116
  @Nullable
117
  public Instant lastCompletion() {
118
    return this.lastCompletion;
3✔
119
  }
120

121
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc