|
20 | 20 |
|
21 | 21 | package io.temporal.internal.client.external;
|
22 | 22 |
|
| 23 | +import com.google.common.base.Preconditions; |
23 | 24 | import com.uber.m3.tally.Scope;
|
24 | 25 | import io.temporal.activity.ManualActivityCompletionClient;
|
25 | 26 | import io.temporal.api.common.v1.WorkflowExecution;
|
26 | 27 | import io.temporal.common.converter.DataConverter;
|
27 | 28 | import io.temporal.serviceclient.WorkflowServiceStubs;
|
28 | 29 | import java.util.Objects;
|
| 30 | +import javax.annotation.Nonnull; |
29 | 31 |
|
30 | 32 | class ManualActivityCompletionClientFactoryImpl implements ManualActivityCompletionClientFactory {
|
31 |
| - |
32 | 33 | private final WorkflowServiceStubs service;
|
33 | 34 | private final DataConverter dataConverter;
|
34 | 35 | private final String namespace;
|
35 | 36 | private final String identity;
|
36 | 37 |
|
37 |
| - public ManualActivityCompletionClientFactoryImpl( |
38 |
| - WorkflowServiceStubs service, |
39 |
| - String namespace, |
40 |
| - String identity, |
41 |
| - DataConverter dataConverter) { |
| 38 | + ManualActivityCompletionClientFactoryImpl( |
| 39 | + @Nonnull WorkflowServiceStubs service, |
| 40 | + @Nonnull String namespace, |
| 41 | + @Nonnull String identity, |
| 42 | + @Nonnull DataConverter dataConverter) { |
42 | 43 | this.service = Objects.requireNonNull(service);
|
43 | 44 | this.namespace = Objects.requireNonNull(namespace);
|
44 | 45 | this.identity = Objects.requireNonNull(identity);
|
45 | 46 | this.dataConverter = Objects.requireNonNull(dataConverter);
|
46 | 47 | }
|
47 | 48 |
|
48 |
| - public WorkflowServiceStubs getService() { |
49 |
| - return service; |
50 |
| - } |
51 |
| - |
52 |
| - public DataConverter getDataConverter() { |
53 |
| - return dataConverter; |
54 |
| - } |
55 |
| - |
56 | 49 | @Override
|
57 |
| - public ManualActivityCompletionClient getClient(byte[] taskToken, Scope metricsScope) { |
58 |
| - // Map<String, String> tags = |
59 |
| - // new ImmutableMap.Builder<String, String>(1).put(MetricsTag.NAMESPACE, |
60 |
| - // namespace).build(); |
61 |
| - // this.metricsScope = metricsScope.tagged(tags); |
62 |
| - |
63 |
| - if (service == null) { |
64 |
| - throw new IllegalStateException("required property service is null"); |
65 |
| - } |
66 |
| - if (dataConverter == null) { |
67 |
| - throw new IllegalStateException("required property dataConverter is null"); |
68 |
| - } |
69 |
| - if (taskToken == null || taskToken.length == 0) { |
70 |
| - throw new IllegalArgumentException("null or empty task token"); |
71 |
| - } |
| 50 | + public ManualActivityCompletionClient getClient(@Nonnull byte[] taskToken, Scope metricsScope) { |
| 51 | + Preconditions.checkArgument( |
| 52 | + taskToken != null && taskToken.length > 0, "null or empty task token"); |
72 | 53 | return new ManualActivityCompletionClientImpl(
|
73 | 54 | service, namespace, identity, taskToken, dataConverter, metricsScope);
|
74 | 55 | }
|
75 | 56 |
|
76 | 57 | @Override
|
77 | 58 | public ManualActivityCompletionClient getClient(
|
78 |
| - WorkflowExecution execution, String activityId, Scope metricsScope) { |
79 |
| - if (execution == null) { |
80 |
| - throw new IllegalArgumentException("null execution"); |
81 |
| - } |
82 |
| - if (activityId == null) { |
83 |
| - throw new IllegalArgumentException("null activityId"); |
84 |
| - } |
| 59 | + @Nonnull WorkflowExecution execution, @Nonnull String activityId, Scope metricsScope) { |
| 60 | + Preconditions.checkArgument(execution != null, "null execution"); |
| 61 | + Preconditions.checkArgument(activityId != null, "null activityId"); |
85 | 62 | return new ManualActivityCompletionClientImpl(
|
86 | 63 | service, namespace, identity, execution, activityId, dataConverter, metricsScope);
|
87 | 64 | }
|
|
0 commit comments