|
24 | 24 |
|
25 | 25 | public class RedisSinkConfig extends RedisConfig {
|
26 | 26 |
|
27 |
| - public enum RedisCommand { |
28 |
| - HSET, JSONSET, TSADD, SET, XADD, LPUSH, RPUSH, SADD, ZADD, DEL |
29 |
| - } |
30 |
| - |
31 |
| - private final Charset charset; |
32 |
| - private final RedisCommand command; |
33 |
| - private final String keyspace; |
34 |
| - private final String separator; |
35 |
| - private final boolean multiexec; |
36 |
| - private final int waitReplicas; |
37 |
| - private final Duration waitTimeout; |
38 |
| - |
39 |
| - public RedisSinkConfig(Map<?, ?> originals) { |
40 |
| - super(new RedisSinkConfigDef(), originals); |
41 |
| - String charsetName = getString(RedisSinkConfigDef.CHARSET_CONFIG).trim(); |
42 |
| - charset = Charset.forName(charsetName); |
43 |
| - command = RedisCommand.valueOf(getString(RedisSinkConfigDef.COMMAND_CONFIG)); |
44 |
| - keyspace = getString(RedisSinkConfigDef.KEY_CONFIG).trim(); |
45 |
| - separator = getString(RedisSinkConfigDef.SEPARATOR_CONFIG).trim(); |
46 |
| - multiexec = Boolean.TRUE.equals(getBoolean(RedisSinkConfigDef.MULTIEXEC_CONFIG)); |
47 |
| - waitReplicas = getInt(RedisSinkConfigDef.WAIT_REPLICAS_CONFIG); |
48 |
| - waitTimeout = Duration.ofMillis(getLong(RedisSinkConfigDef.WAIT_TIMEOUT_CONFIG)); |
49 |
| - } |
50 |
| - |
51 |
| - public Charset getCharset() { |
52 |
| - return charset; |
53 |
| - } |
54 |
| - |
55 |
| - public RedisCommand getCommand() { |
56 |
| - return command; |
57 |
| - } |
58 |
| - |
59 |
| - public String getKeyspace() { |
60 |
| - return keyspace; |
61 |
| - } |
62 |
| - |
63 |
| - public String getSeparator() { |
64 |
| - return separator; |
65 |
| - } |
66 |
| - |
67 |
| - public boolean isMultiexec() { |
68 |
| - return multiexec; |
69 |
| - } |
70 |
| - |
71 |
| - public int getWaitReplicas() { |
72 |
| - return waitReplicas; |
73 |
| - } |
74 |
| - |
75 |
| - public Duration getWaitTimeout() { |
76 |
| - return waitTimeout; |
77 |
| - } |
78 |
| - |
79 |
| - @Override |
80 |
| - public int hashCode() { |
81 |
| - final int prime = 31; |
82 |
| - int result = super.hashCode(); |
83 |
| - result = prime * result |
84 |
| - + Objects.hash(charset, keyspace, separator, multiexec, command, waitReplicas, waitTimeout); |
85 |
| - return result; |
86 |
| - } |
87 |
| - |
88 |
| - @Override |
89 |
| - public boolean equals(Object obj) { |
90 |
| - if (this == obj) |
91 |
| - return true; |
92 |
| - if (!super.equals(obj)) |
93 |
| - return false; |
94 |
| - if (getClass() != obj.getClass()) |
95 |
| - return false; |
96 |
| - RedisSinkConfig other = (RedisSinkConfig) obj; |
97 |
| - return Objects.equals(charset, other.charset) && Objects.equals(keyspace, other.keyspace) |
98 |
| - && Objects.equals(separator, other.separator) && multiexec == other.multiexec |
99 |
| - && command == other.command && waitReplicas == other.waitReplicas && waitTimeout == other.waitTimeout; |
100 |
| - } |
| 27 | + public enum RedisCommand { |
| 28 | + HSET, JSONSET, TSADD, SET, XADD, LPUSH, RPUSH, SADD, ZADD, DEL |
| 29 | + } |
| 30 | + |
| 31 | + public static final RedisSinkConfigDef CONFIG = new RedisSinkConfigDef(); |
| 32 | + |
| 33 | + private final Charset charset; |
| 34 | + |
| 35 | + private final RedisCommand command; |
| 36 | + |
| 37 | + private final String keyspace; |
| 38 | + |
| 39 | + private final String separator; |
| 40 | + |
| 41 | + private final boolean multiexec; |
| 42 | + |
| 43 | + private final int waitReplicas; |
| 44 | + |
| 45 | + private final Duration waitTimeout; |
| 46 | + |
| 47 | + public RedisSinkConfig(Map<?, ?> originals) { |
| 48 | + super(new RedisSinkConfigDef(), originals); |
| 49 | + String charsetName = getString(RedisSinkConfigDef.CHARSET_CONFIG).trim(); |
| 50 | + charset = Charset.forName(charsetName); |
| 51 | + command = RedisCommand.valueOf(getString(RedisSinkConfigDef.COMMAND_CONFIG)); |
| 52 | + keyspace = getString(RedisSinkConfigDef.KEY_CONFIG).trim(); |
| 53 | + separator = getString(RedisSinkConfigDef.SEPARATOR_CONFIG).trim(); |
| 54 | + multiexec = Boolean.TRUE.equals(getBoolean(RedisSinkConfigDef.MULTIEXEC_CONFIG)); |
| 55 | + waitReplicas = getInt(RedisSinkConfigDef.WAIT_REPLICAS_CONFIG); |
| 56 | + waitTimeout = Duration.ofMillis(getLong(RedisSinkConfigDef.WAIT_TIMEOUT_CONFIG)); |
| 57 | + } |
| 58 | + |
| 59 | + public Charset getCharset() { |
| 60 | + return charset; |
| 61 | + } |
| 62 | + |
| 63 | + public RedisCommand getCommand() { |
| 64 | + return command; |
| 65 | + } |
| 66 | + |
| 67 | + public String getKeyspace() { |
| 68 | + return keyspace; |
| 69 | + } |
| 70 | + |
| 71 | + public String getSeparator() { |
| 72 | + return separator; |
| 73 | + } |
| 74 | + |
| 75 | + public boolean isMultiexec() { |
| 76 | + return multiexec; |
| 77 | + } |
| 78 | + |
| 79 | + public int getWaitReplicas() { |
| 80 | + return waitReplicas; |
| 81 | + } |
| 82 | + |
| 83 | + public Duration getWaitTimeout() { |
| 84 | + return waitTimeout; |
| 85 | + } |
| 86 | + |
| 87 | + @Override |
| 88 | + public int hashCode() { |
| 89 | + final int prime = 31; |
| 90 | + int result = super.hashCode(); |
| 91 | + result = prime * result + Objects.hash(charset, keyspace, separator, multiexec, command, waitReplicas, waitTimeout); |
| 92 | + return result; |
| 93 | + } |
| 94 | + |
| 95 | + @Override |
| 96 | + public boolean equals(Object obj) { |
| 97 | + if (this == obj) |
| 98 | + return true; |
| 99 | + if (!super.equals(obj)) |
| 100 | + return false; |
| 101 | + if (getClass() != obj.getClass()) |
| 102 | + return false; |
| 103 | + RedisSinkConfig other = (RedisSinkConfig) obj; |
| 104 | + return Objects.equals(charset, other.charset) && Objects.equals(keyspace, other.keyspace) |
| 105 | + && Objects.equals(separator, other.separator) && multiexec == other.multiexec && command == other.command |
| 106 | + && waitReplicas == other.waitReplicas && waitTimeout == other.waitTimeout; |
| 107 | + } |
101 | 108 |
|
102 | 109 | }
|
0 commit comments