Replace if..else with switch in TypeMessageBuilderImpl
@@ -236,26 +236,35 @@ public class TypedMessageBuilderImpl<T> implements TypedMessageBuilder<T> {
@Override
public TypedMessageBuilder<T> loadConf(Map<String, Object> config) {
config.forEach((key, value) -> {
- if (key.equals(CONF_KEY)) {
+ switch (key) {
+ case CONF_KEY:
this.key(checkType(value, String.class));
- } else if (key.equals(CONF_PROPERTIES)) {
+ break;
+ case CONF_PROPERTIES:
this.properties(checkType(value, Map.class));
- } else if (key.equals(CONF_EVENT_TIME)) {
+ break;
+ case CONF_EVENT_TIME:
this.eventTime(checkType(value, Long.class));
- } else if (key.equals(CONF_SEQUENCE_ID)) {
+ break;
+ case CONF_SEQUENCE_ID:
this.sequenceId(checkType(value, Long.class));
- } else if (key.equals(CONF_REPLICATION_CLUSTERS)) {
+ break;
+ case CONF_REPLICATION_CLUSTERS:
this.replicationClusters(checkType(value, List.class));
- } else if (key.equals(CONF_DISABLE_REPLICATION)) {
+ break;
+ case CONF_DISABLE_REPLICATION:
boolean disableReplication = checkType(value, Boolean.class);
if (disableReplication) {
this.disableReplication();
}
- } else if (key.equals(CONF_DELIVERY_AFTER_SECONDS)) {
+ break;
+ case CONF_DELIVERY_AFTER_SECONDS:
this.deliverAfter(checkType(value, Long.class), TimeUnit.SECONDS);
- } else if (key.equals(CONF_DELIVERY_AT)) {
+ break;
+ case CONF_DELIVERY_AT:
this.deliverAt(checkType(value, Long.class));
- } else {
+ break;
+ default:
throw new RuntimeException("Invalid message config key '" + key + "'");
}
});
