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

temporalio / sdk-java / #120

pending completion
#120

push

github-actions

web-flow
Rename sdk-features to features (#1599)

16189 of 20022 relevant lines covered (80.86%)

0.81 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/WorkflowExecutionMetadata.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;
22

23
import com.google.common.base.Preconditions;
24
import io.temporal.api.common.v1.Payload;
25
import io.temporal.api.common.v1.WorkflowExecution;
26
import io.temporal.api.enums.v1.WorkflowExecutionStatus;
27
import io.temporal.api.workflow.v1.WorkflowExecutionInfo;
28
import io.temporal.common.converter.DataConverter;
29
import io.temporal.internal.common.ProtobufTimeUtils;
30
import io.temporal.internal.common.SearchAttributesUtil;
31
import java.lang.reflect.Type;
32
import java.time.Instant;
33
import java.util.Collections;
34
import java.util.List;
35
import java.util.Map;
36
import java.util.Objects;
37
import javax.annotation.Nonnull;
38
import javax.annotation.Nullable;
39

40
public class WorkflowExecutionMetadata {
41
  private final @Nonnull WorkflowExecutionInfo info;
42
  private final @Nonnull DataConverter dataConverter;
43

44
  WorkflowExecutionMetadata(
45
      @Nonnull WorkflowExecutionInfo info, @Nonnull DataConverter dataConverter) {
46
    this.info = Preconditions.checkNotNull(info, "info");
47
    this.dataConverter = Preconditions.checkNotNull(dataConverter, "dataConverter");
48
  }
49

50
  @Nonnull
51
  public WorkflowExecution getExecution() {
52
    return info.getExecution();
53
  }
54

55
  @Nonnull
56
  public String getWorkflowType() {
57
    return info.getType().getName();
58
  }
59

60
  @Nonnull
61
  public String getTaskQueue() {
62
    return info.getTaskQueue();
63
  }
64

65
  @Nonnull
66
  public Instant getStartTime() {
67
    return ProtobufTimeUtils.toJavaInstant(info.getStartTime());
68
  }
69

70
  @Nonnull
71
  public Instant getExecutionTime() {
72
    return ProtobufTimeUtils.toJavaInstant(info.getExecutionTime());
73
  }
74

75
  @Nullable
76
  public Instant getCloseTime() {
77
    return info.hasCloseTime() ? ProtobufTimeUtils.toJavaInstant(info.getCloseTime()) : null;
78
  }
79

80
  @Nonnull
81
  public WorkflowExecutionStatus getStatus() {
82
    return info.getStatus();
83
  }
84

85
  public long getHistoryLength() {
86
    return info.getHistoryLength();
87
  }
88

89
  @Nullable
90
  public String getParentNamespace() {
91
    return info.hasParentExecution() ? info.getParentNamespaceId() : null;
92
  }
93

94
  @Nullable
95
  public WorkflowExecution getParentExecution() {
96
    return info.hasParentExecution() ? info.getParentExecution() : null;
97
  }
98

99
  @Nonnull
100
  public Map<String, List<?>> getSearchAttributes() {
101
    return Collections.unmodifiableMap(SearchAttributesUtil.decode(info.getSearchAttributes()));
102
  }
103

104
  @Nullable
105
  public <T> Object getMemo(String key, Class<T> valueClass) {
106
    return getMemo(key, valueClass, valueClass);
107
  }
108

109
  @Nullable
110
  public <T> T getMemo(String key, Class<T> valueClass, Type genericType) {
111
    Payload memo = info.getMemo().getFieldsMap().get(key);
112
    if (memo == null) {
113
      return null;
114
    }
115
    return dataConverter.fromPayload(memo, valueClass, genericType);
116
  }
117

118
  @Nonnull
119
  public WorkflowExecutionInfo getWorkflowExecutionInfo() {
120
    return info;
121
  }
122

123
  @Override
124
  public boolean equals(Object o) {
125
    if (this == o) return true;
126
    if (o == null || getClass() != o.getClass()) return false;
127
    WorkflowExecutionMetadata that = (WorkflowExecutionMetadata) o;
128
    return info.equals(that.info);
129
  }
130

131
  @Override
132
  public int hashCode() {
133
    return Objects.hash(info);
134
  }
135
}
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