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

temporalio / sdk-java / #174

pending completion
#174

push

github-actions

web-flow
Add schedules API (#1776)

Add schedules API

1143 of 1143 new or added lines in 35 files covered. (100.0%)

18101 of 23284 relevant lines covered (77.74%)

0.78 hits per line

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

0.0
/temporal-sdk/src/main/java/io/temporal/client/schedules/ScheduleState.java
1
/*
2
 * Copyright (C) 2022 Temporal Technologies, Inc. All Rights Reserved.
3
 *
4
 * Copyright (C) 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
5
 *
6
 * Modifications copyright (C) 2017 Uber Technologies, Inc.
7
 *
8
 * Licensed under the Apache License, Version 2.0 (the "License");
9
 * you may not use this material except in compliance with the License.
10
 * You may obtain a copy of the License at
11
 *
12
 *   http://www.apache.org/licenses/LICENSE-2.0
13
 *
14
 * Unless required by applicable law or agreed to in writing, software
15
 * distributed under the License is distributed on an "AS IS" BASIS,
16
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
 * See the License for the specific language governing permissions and
18
 * limitations under the License.
19
 */
20

21
package io.temporal.client.schedules;
22

23
import java.util.Objects;
24

25
/** State of a schedule. */
26
public final class ScheduleState {
27
  public static ScheduleState.Builder newBuilder() {
28
    return new ScheduleState.Builder();
×
29
  }
30

31
  public static ScheduleState.Builder newBuilder(ScheduleState options) {
32
    return new ScheduleState.Builder(options);
×
33
  }
34

35
  public static final class Builder {
36
    private String note;
37
    private boolean paused;
38
    private boolean limitedAction;
39
    private long remainingActions;
40

41
    private Builder() {}
42

43
    private Builder(ScheduleState options) {
×
44
      if (options == null) {
×
45
        return;
×
46
      }
47
      this.note = options.note;
×
48
      this.paused = options.paused;
×
49
      this.limitedAction = options.limitedAction;
×
50
      this.remainingActions = options.remainingActions;
×
51
    }
×
52

53
    /** Set a human-readable message for the schedule. */
54
    public Builder setNote(String note) {
55
      this.note = note;
×
56
      return this;
×
57
    }
58

59
    /** Set whether this schedule is paused. */
60
    public Builder setPaused(boolean paused) {
61
      this.paused = paused;
×
62
      return this;
×
63
    }
64

65
    /** Set ,if true, whether remaining actions will be decremented for each action */
66
    public Builder setLimitedAction(boolean limitedAction) {
67
      this.limitedAction = limitedAction;
×
68
      return this;
×
69
    }
70

71
    /**
72
     * Set the actions remaining on this schedule. Once this number hits 0, no further actions are
73
     * scheduled automatically.
74
     */
75
    public Builder setRemainingActions(long remainingActions) {
76
      this.remainingActions = remainingActions;
×
77
      return this;
×
78
    }
79

80
    public ScheduleState build() {
81
      return new ScheduleState(note, paused, limitedAction, remainingActions);
×
82
    }
83
  }
84

85
  private final String note;
86
  private final boolean paused;
87
  private final boolean limitedAction;
88
  private final long remainingActions;
89

90
  private ScheduleState(String note, boolean paused, boolean limitedAction, long remainingActions) {
×
91
    this.note = note;
×
92
    this.paused = paused;
×
93
    this.limitedAction = limitedAction;
×
94
    this.remainingActions = remainingActions;
×
95
  }
×
96

97
  /**
98
   * Gets the human-readable message for the schedule.
99
   *
100
   * @return the schedules note
101
   */
102
  public String getNote() {
103
    return note;
×
104
  }
105

106
  /**
107
   * Gets a value indicating whether this schedule is paused.
108
   *
109
   * @return if the schedule is paused
110
   */
111
  public boolean isPaused() {
112
    return paused;
×
113
  }
114

115
  /**
116
   * Gets a value indicating whether, if true, remaining actions will be decremented for each action
117
   * taken.
118
   *
119
   * @return if the schedule has limited actions
120
   */
121
  public boolean isLimitedAction() {
122
    return limitedAction;
×
123
  }
124

125
  /**
126
   * Gets the actions remaining on this schedule. Once this number hits 0, no further actions are
127
   * scheduled automatically.
128
   *
129
   * @return the number of remaining actions
130
   */
131
  public long getRemainingActions() {
132
    return remainingActions;
×
133
  }
134

135
  @Override
136
  public boolean equals(Object o) {
137
    if (this == o) return true;
×
138
    if (o == null || getClass() != o.getClass()) return false;
×
139
    ScheduleState that = (ScheduleState) o;
×
140
    return paused == that.paused
×
141
        && limitedAction == that.limitedAction
142
        && remainingActions == that.remainingActions
143
        && Objects.equals(note, that.note);
×
144
  }
145

146
  @Override
147
  public int hashCode() {
148
    return Objects.hash(note, paused, limitedAction, remainingActions);
×
149
  }
150

151
  @Override
152
  public String toString() {
153
    return "ScheduleState{"
×
154
        + "note='"
155
        + note
156
        + '\''
157
        + ", paused="
158
        + paused
159
        + ", limitedAction="
160
        + limitedAction
161
        + ", remainingActions="
162
        + remainingActions
163
        + '}';
164
  }
165
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc