• 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/Schedule.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
import javax.annotation.Nonnull;
25
import javax.annotation.Nullable;
26

27
/** A schedule for periodically running an action. */
28
public final class Schedule {
29
  public static Schedule.Builder newBuilder() {
30
    return new Schedule.Builder();
×
31
  }
32

33
  public static Schedule.Builder newBuilder(Schedule options) {
34
    return new Schedule.Builder(options);
×
35
  }
36

37
  public static final class Builder {
38
    private ScheduleAction action;
39
    private ScheduleSpec spec;
40
    private SchedulePolicy policy;
41
    private ScheduleState state;
42

43
    private Builder() {}
44

45
    private Builder(Schedule options) {
×
46
      if (options == null) {
×
47
        return;
×
48
      }
49
      action = options.action;
×
50
      policy = options.policy;
×
51
      state = options.state;
×
52
      spec = options.spec;
×
53
    }
×
54

55
    /**
56
     * Set the action for this schedule. Required to build.
57
     *
58
     * @see ScheduleAction
59
     */
60
    public Builder setAction(ScheduleAction action) {
61
      this.action = action;
×
62
      return this;
×
63
    }
64

65
    /**
66
     * Set the spec for this schedule. Required to build.
67
     *
68
     * @see ScheduleSpec
69
     */
70
    public Builder setSpec(ScheduleSpec spec) {
71
      this.spec = spec;
×
72
      return this;
×
73
    }
74

75
    /**
76
     * Set the spec for this schedule
77
     *
78
     * @see ScheduleSpec
79
     */
80
    public Builder setPolicy(SchedulePolicy policy) {
81
      this.policy = policy;
×
82
      return this;
×
83
    }
84

85
    /**
86
     * Set the state for this schedule
87
     *
88
     * @see ScheduleState
89
     */
90
    public Builder setState(ScheduleState state) {
91
      this.state = state;
×
92
      return this;
×
93
    }
94

95
    public Schedule build() {
96
      return new Schedule(
×
97
          Objects.requireNonNull(action), Objects.requireNonNull(spec), policy, state);
×
98
    }
99
  }
100

101
  private final ScheduleAction action;
102
  private final SchedulePolicy policy;
103
  private final ScheduleState state;
104
  private final ScheduleSpec spec;
105

106
  private Schedule(
107
      ScheduleAction action, ScheduleSpec spec, SchedulePolicy policy, ScheduleState state) {
×
108
    this.action = action;
×
109
    this.spec = spec;
×
110
    this.policy = policy;
×
111
    this.state = state;
×
112
  }
×
113

114
  /**
115
   * Gets the action for the schedule.
116
   *
117
   * @return action of the schedule
118
   */
119
  @Nonnull
120
  public ScheduleAction getAction() {
121
    return action;
×
122
  }
123

124
  /**
125
   * Gets the spec for the schedule.
126
   *
127
   * @return spec of the schedule
128
   */
129
  @Nonnull
130
  public ScheduleSpec getSpec() {
131
    return spec;
×
132
  }
133

134
  /**
135
   * Gets the policy for the schedule.
136
   *
137
   * @return policy of the schedule
138
   */
139
  @Nullable
140
  public SchedulePolicy getPolicy() {
141
    return policy;
×
142
  }
143

144
  /**
145
   * Gets the state of the schedule.
146
   *
147
   * @return state of the schedule
148
   */
149
  @Nullable
150
  public ScheduleState getState() {
151
    return state;
×
152
  }
153

154
  @Override
155
  public boolean equals(Object o) {
156
    if (this == o) return true;
×
157
    if (o == null || getClass() != o.getClass()) return false;
×
158
    Schedule schedule = (Schedule) o;
×
159
    return Objects.equals(action, schedule.action)
×
160
        && Objects.equals(policy, schedule.policy)
×
161
        && Objects.equals(state, schedule.state)
×
162
        && Objects.equals(spec, schedule.spec);
×
163
  }
164

165
  @Override
166
  public int hashCode() {
167
    return Objects.hash(action, policy, state, spec);
×
168
  }
169

170
  @Override
171
  public String toString() {
172
    return "Schedule{"
×
173
        + "action="
174
        + action
175
        + ", policy="
176
        + policy
177
        + ", state="
178
        + state
179
        + ", spec="
180
        + spec
181
        + '}';
182
  }
183
}
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