pandaapo commented on code in PR #4569:
URL: https://github.com/apache/eventmesh/pull/4569#discussion_r1399046377
##########
eventmesh-openconnect/eventmesh-openconnect-offsetmgmt-plugin/eventmesh-openconnect-offsetmgmt-api/src/main/java/org/apache/eventmesh/openconnect/offsetmgmt/api/data/DefaultKeyValue.java:
##########
@@ -17,71 +17,85 @@
package org.apache.eventmesh.openconnect.offsetmgmt.api.data;
+import java.net.URI;
+import java.time.OffsetDateTime;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
public class DefaultKeyValue implements KeyValue {
- private Map<String, Object> properties = new ConcurrentHashMap<>();
+ private final Map<String, Object> properties;
+
+ public DefaultKeyValue() {
+ properties = new ConcurrentHashMap<>();
+ }
+
@Override
- public boolean getBoolean(String key) {
- if (!properties.containsKey(key)) {
- return false;
- }
- return Boolean.parseBoolean(String.valueOf(properties.get(key)));
+ public KeyValue put(String key, boolean value) {
+ properties.put(key, value);
+ return this;
}
@Override
- public boolean getBoolean(String key, boolean defaultValue) {
- return properties.containsKey(key) ? getBoolean(key) : defaultValue;
+ public KeyValue put(String key, byte value) {
+ properties.put(key, value);
+ return this;
+
}
@Override
- public short getShort(String key) {
- if (!properties.containsKey(key)) {
- return 0;
- }
- return Short.parseShort(String.valueOf(properties.get(key)));
+ public KeyValue put(String key, short value) {
+ properties.put(key, value);
+ return this;
}
@Override
- public short getShort(String key, short defaultValue) {
- return properties.containsKey(key) ? getShort(key) : defaultValue;
+ public KeyValue put(String key, int value) {
+ properties.put(key, value);
+ return this;
}
@Override
- public KeyValue put(String key, boolean value) {
- properties.put(key, String.valueOf(value));
+ public KeyValue put(String key, long value) {
+ properties.put(key, value);
return this;
}
@Override
- public KeyValue put(String key, short value) {
- properties.put(key, String.valueOf(value));
+ public KeyValue put(String key, float value) {
+ properties.put(key, value);
return this;
}
- public DefaultKeyValue() {
- properties = new ConcurrentHashMap<String, Object>();
+ @Override
+ public KeyValue put(String key, double value) {
+ properties.put(key, value);
+ return this;
Review Comment:
Could these numeric types of `put(String, short/int/long/float/double)`
methods be simplified to a `put(String, Number)`?
这些数字类型的`put(String, short/int/long/float/double)`方法,是否可以简化成一个`put(String,
Number)`?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]