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

temporalio / sdk-java / #392

21 Sep 2026 10:15PM UTC coverage: 68.317% (+0.04%) from 68.278%
#392

push

github

web-flow
Add support for setting ActivityID (#3044)

Add support for setting Activity ID

7892 of 13700 branches covered (57.61%)

Branch coverage included in aggregate %.

119 of 176 new or added lines in 11 files covered. (67.61%)

4 existing lines in 2 files now uncovered.

32034 of 44742 relevant lines covered (71.6%)

0.72 hits per line

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

61.11
/temporal-sdk/src/main/java/io/temporal/workflow/ActivityInvocationOptions.java
1
package io.temporal.workflow;
2

3
import io.temporal.common.Experimental;
4
import java.util.Objects;
5
import javax.annotation.Nullable;
6

7
/** Options that apply to a single Workflow Activity or Local Activity invocation. */
8
@Experimental
9
public final class ActivityInvocationOptions {
10

11
  public static Builder newBuilder() {
12
    return new Builder();
1 ✔
13
  }
14

15
  public static Builder newBuilder(ActivityInvocationOptions options) {
16
    return new Builder(options);
1 ✔
17
  }
18

19
  public static ActivityInvocationOptions getDefaultInstance() {
20
    return DEFAULT_INSTANCE;
1 ✔
21
  }
22

23
  private static final ActivityInvocationOptions DEFAULT_INSTANCE;
24

25
  static {
26
    DEFAULT_INSTANCE = ActivityInvocationOptions.newBuilder().build();
1 ✔
27
  }
1 ✔
28

29
  public static final class Builder {
30
    private String activityId;
31

32
    private Builder() {}
33

34
    private Builder(ActivityInvocationOptions options) {
1 ✔
35
      if (options != null) {
1 !
36
        this.activityId = options.activityId;
1 ✔
37
      }
38
    }
1 ✔
39

40
    /**
41
     * Sets the identifier for this Activity or Local Activity invocation.
42
     *
43
     * <p>The identifier must be unique among open Activity Executions within the current Workflow
44
     * Run. If it is not set, the SDK generates an identifier.
45
     */
46
    public Builder setActivityId(String activityId) {
47
      Objects.requireNonNull(activityId, "activityId");
1 ✔
48
      if (activityId.isEmpty()) {
1 ✔
49
        throw new IllegalArgumentException("activityId must not be empty");
1 ✔
50
      }
51
      this.activityId = activityId;
1 ✔
52
      return this;
1 ✔
53
    }
54

55
    public ActivityInvocationOptions build() {
56
      return new ActivityInvocationOptions(activityId);
1 ✔
57
    }
58
  }
59

60
  private final String activityId;
61

62
  private ActivityInvocationOptions(String activityId) {
1 ✔
63
    this.activityId = activityId;
1 ✔
64
  }
1 ✔
65

66
  /** Returns the caller-supplied Activity ID, or {@code null} if the SDK should generate one. */
67
  @Nullable
68
  public String getActivityId() {
69
    return activityId;
1 ✔
70
  }
71

72
  public Builder toBuilder() {
NEW
73
    return new Builder(this);
×
74
  }
75

76
  @Override
77
  public boolean equals(Object o) {
NEW
78
    if (this == o) return true;
×
NEW
79
    if (o == null || getClass() != o.getClass()) return false;
×
NEW
80
    ActivityInvocationOptions that = (ActivityInvocationOptions) o;
×
NEW
81
    return Objects.equals(activityId, that.activityId);
×
82
  }
83

84
  @Override
85
  public int hashCode() {
NEW
86
    return Objects.hash(activityId);
×
87
  }
88

89
  @Override
90
  public String toString() {
NEW
91
    return "ActivityInvocationOptions{" + "activityId='" + activityId + '\'' + '}';
×
92
  }
93
}
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