1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.shardingsphere.data.pipeline.core.context;
19
20 import lombok.Getter;
21 import lombok.RequiredArgsConstructor;
22 import org.apache.shardingsphere.infra.instance.metadata.InstanceType;
23
24 import java.util.Objects;
25
26
27
28
29 @RequiredArgsConstructor
30 @Getter
31 public final class PipelineContextKey {
32
33 private final String databaseName;
34
35 private final InstanceType instanceType;
36
37 public PipelineContextKey(final InstanceType instanceType) {
38 this("", instanceType);
39 }
40
41 @Override
42 public boolean equals(final Object o) {
43 if (this == o) {
44 return true;
45 }
46 if (null == o || getClass() != o.getClass()) {
47 return false;
48 }
49 final PipelineContextKey that = (PipelineContextKey) o;
50 return instanceType == that.instanceType && Objects.equals(filterDatabaseName(this), filterDatabaseName(that));
51 }
52
53 private String filterDatabaseName(final PipelineContextKey contextKey) {
54 return InstanceType.PROXY == contextKey.getInstanceType() ? "" : contextKey.getDatabaseName();
55 }
56
57 @Override
58 public int hashCode() {
59 return Objects.hash(instanceType, filterDatabaseName(this));
60 }
61 }