1 package net.secodo.jcircuitbreaker.breaker.execution;
2
3 import java.util.Objects;
4 import net.secodo.jcircuitbreaker.task.Task;
5
6
7
8
9
10
11
12
13
14
15 public class ExecutedTask<R> {
16 private final Task<R> task;
17 private final long executionStartedTimestamp;
18
19 public ExecutedTask(Task<R> task, long executionStartedTimestamp) {
20 this.task = task;
21 this.executionStartedTimestamp = executionStartedTimestamp;
22 }
23
24 public long getExecutionStartedTimestamp() {
25 return executionStartedTimestamp;
26 }
27
28 public Task<R> getTask() {
29 return task;
30 }
31
32
33 @Override
34 public boolean equals(Object other) {
35 if (this == other) {
36 return true;
37 }
38 if (!(other instanceof ExecutedTask)) {
39 return false;
40 }
41
42 ExecutedTask<?> that = (ExecutedTask<?>) other;
43 return (executionStartedTimestamp == that.executionStartedTimestamp) &&
44 Objects.equals(task, that.task);
45 }
46
47 @Override
48 public int hashCode() {
49 return Objects.hash(task, executionStartedTimestamp);
50 }
51
52 }