Skip to content

Commit 888cb82

Browse files
Add deprecation notices
1 parent 183d8bd commit 888cb82

File tree

2 files changed

+55
-10
lines changed

2 files changed

+55
-10
lines changed

temporal-sdk/src/main/java/io/temporal/client/WorkflowClient.java

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -147,19 +147,11 @@ static WorkflowClient newInstance(WorkflowServiceStubs service, WorkflowClientOp
147147
* @param workflowInterface interface that given workflow implements.
148148
* @param workflowId Workflow id.
149149
* @return Stub that implements workflowInterface and can be used to signal or query it.
150+
* @deprecated Use {@link #newWorkflowStub(Class, WorkflowTargetOptions)} instead.
150151
*/
152+
@Deprecated
151153
<T> T newWorkflowStub(Class<T> workflowInterface, String workflowId);
152154

153-
/**
154-
* Creates workflow client stub for a known execution. Use it to send signals or queries to a
155-
* running workflow. Do not call methods annotated with @WorkflowMethod.
156-
*
157-
* @param workflowInterface interface that given workflow implements.
158-
* @param workflowTargetOptions options that specify target workflow execution.
159-
* @return Stub that implements workflowInterface and can be used to signal or query it.
160-
*/
161-
<T> T newWorkflowStub(Class<T> workflowInterface, WorkflowTargetOptions workflowTargetOptions);
162-
163155
/**
164156
* Creates workflow client stub for a known execution. Use it to send signals, updates, or queries
165157
* to a running workflow. Do not call methods annotated with @WorkflowMethod.
@@ -168,9 +160,21 @@ static WorkflowClient newInstance(WorkflowServiceStubs service, WorkflowClientOp
168160
* @param workflowId Workflow id.
169161
* @param runId Run id of the workflow execution.
170162
* @return Stub that implements workflowInterface and can be used to signal, update, or query it.
163+
* @deprecated Use {@link #newWorkflowStub(Class, WorkflowTargetOptions)} instead.
171164
*/
165+
@Deprecated
172166
<T> T newWorkflowStub(Class<T> workflowInterface, String workflowId, Optional<String> runId);
173167

168+
/**
169+
* Creates workflow client stub for a known execution. Use it to send signals or queries to a
170+
* running workflow. Do not call methods annotated with @WorkflowMethod.
171+
*
172+
* @param workflowInterface interface that given workflow implements.
173+
* @param workflowTargetOptions options that specify target workflow execution.
174+
* @return Stub that implements workflowInterface and can be used to signal or query it.
175+
*/
176+
<T> T newWorkflowStub(Class<T> workflowInterface, WorkflowTargetOptions workflowTargetOptions);
177+
174178
/**
175179
* Creates workflow untyped client stub that can be used to start a single workflow execution. Use
176180
* it to send signals or queries to a running workflow. Do not call methods annotated
@@ -201,7 +205,9 @@ static WorkflowClient newInstance(WorkflowServiceStubs service, WorkflowClientOp
201205
* workflowId is assumed.
202206
* @param workflowType type of the workflow. Optional as it is used for error reporting only.
203207
* @return Stub that can be used to start workflow and later to signal or query it.
208+
* @deprecated Use {@link #newUntypedWorkflowStub(Optional, WorkflowTargetOptions)} instead.
204209
*/
210+
@Deprecated
205211
WorkflowStub newUntypedWorkflowStub(
206212
String workflowId, Optional<String> runId, Optional<String> workflowType);
207213

@@ -212,6 +218,7 @@ WorkflowStub newUntypedWorkflowStub(
212218
* @param execution workflow id and optional run id for execution
213219
* @param workflowType type of the workflow. Optional as it is used for error reporting only.
214220
* @return Stub that can be used to start workflow and later to signal or query it.
221+
* @deprecated Use {@link #newUntypedWorkflowStub(Optional, WorkflowTargetOptions)} instead.
215222
*/
216223
WorkflowStub newUntypedWorkflowStub(WorkflowExecution execution, Optional<String> workflowType);
217224

temporal-sdk/src/main/java/io/temporal/client/WorkflowTargetOptions.java

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package io.temporal.client;
22

33
import io.temporal.api.common.v1.WorkflowExecution;
4+
import java.util.Objects;
45

6+
/** Options for targeting a specific workflow execution. */
57
public final class WorkflowTargetOptions {
68
public static WorkflowTargetOptions.Builder newBuilder() {
79
return new WorkflowTargetOptions.Builder();
@@ -56,21 +58,28 @@ private Builder(WorkflowTargetOptions options) {
5658
this.firstExecutionRunId = options.firstExecutionRunId;
5759
}
5860

61+
/** Sets the workflowId of the target workflow. */
5962
public Builder setWorkflowId(String workflowId) {
6063
this.workflowId = workflowId;
6164
return this;
6265
}
6366

67+
/** Sets the runId of a specific execution of a workflow. */
6468
public Builder setRunId(String runId) {
6569
this.runId = runId;
6670
return this;
6771
}
6872

73+
/**
74+
* Sets the runId of the first execution of a workflow. This is useful for targeting workflows
75+
* that have been continued as new.
76+
*/
6977
public Builder setFirstExecutionRunId(String firstExecutionRunId) {
7078
this.firstExecutionRunId = firstExecutionRunId;
7179
return this;
7280
}
7381

82+
/** Sets both workflowId and runId from a WorkflowExecution object. */
7483
public Builder setWorkflowExecution(WorkflowExecution execution) {
7584
this.workflowId = execution.getWorkflowId();
7685
this.runId = execution.getRunId();
@@ -81,4 +90,33 @@ public WorkflowTargetOptions build() {
8190
return new WorkflowTargetOptions(workflowId, runId, firstExecutionRunId);
8291
}
8392
}
93+
94+
@Override
95+
public String toString() {
96+
return "WorkflowTargetOptions{"
97+
+ "workflowId='"
98+
+ workflowId
99+
+ '\''
100+
+ ", runId='"
101+
+ runId
102+
+ '\''
103+
+ ", firstExecutionRunId='"
104+
+ firstExecutionRunId
105+
+ '\''
106+
+ '}';
107+
}
108+
109+
@Override
110+
public boolean equals(Object o) {
111+
if (o == null || getClass() != o.getClass()) return false;
112+
WorkflowTargetOptions that = (WorkflowTargetOptions) o;
113+
return Objects.equals(workflowId, that.workflowId)
114+
&& Objects.equals(runId, that.runId)
115+
&& Objects.equals(firstExecutionRunId, that.firstExecutionRunId);
116+
}
117+
118+
@Override
119+
public int hashCode() {
120+
return Objects.hash(workflowId, runId, firstExecutionRunId);
121+
}
84122
}

0 commit comments

Comments
 (0)