[ISSUE #4269] Used switch to replace the if-else. [MeshMessageProtocolAdaptor]#4270
[ISSUE #4269] Used switch to replace the if-else. [MeshMessageProtocolAdaptor]#4270xwm1992 merged 4 commits intoapache:masterfrom devCod3r:developmentEM
Conversation
| } | ||
| map.put(MeshMessageProtocolConstant.PROTOCOL_KEY_CONTENT, new String(cloudEvent.getData().toBytes(), StandardCharsets.UTF_8)); |
There was a problem hiding this comment.
StandardCharsets.UTF_8 replace with Constants.DEFAULT_CHARSET
Codecov Report
@@ Coverage Diff @@
## master #4270 +/- ##
=========================================
Coverage 16.86% 16.87%
Complexity 1426 1426
=========================================
Files 593 593
Lines 26073 26068 -5
Branches 2401 2396 -5
=========================================
Hits 4398 4398
+ Misses 21234 21229 -5
Partials 441 441
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
| case MSG_BATCH_SEND_V2: | ||
| return SendMessageBatchV2ProtocolResolver.buildEvent(header, body); | ||
| case MSG_SEND_SYNC: | ||
| return SendMessageRequestProtocolResolver.buildEvent(header, body); |
There was a problem hiding this comment.
Merged both the Cases.
| @Override | ||
| public Map<String, Object> toMap() { | ||
| if (cloudEvent.getData() == null) { | ||
| cloudEvent.getExtension(Constants.PROTOCOL_DESC) == null ? null : cloudEvent.getExtension(Constants.PROTOCOL_DESC).toString(); |
There was a problem hiding this comment.
No change needs to be made in this line.
There was a problem hiding this comment.
Reverted back the changes (Removed few white spaces).
| map.put(MeshMessageProtocolConstant.PROTOCOL_KEY_CONTENT, new String(cloudEvent.getData().toBytes(), | ||
| Constants.DEFAULT_CHARSET)); |
There was a problem hiding this comment.
Consider putting the second argument on the same line.
There was a problem hiding this comment.
Like this:
map.put(MeshMessageProtocolConstant.PROTOCOL_KEY_CONTENT,
new String(cloudEvent.getData().toBytes(), Constants.DEFAULT_CHARSET));Because new String(cloudEvent.getData().toBytes(), Constants.DEFAULT_CHARSET) is the second argument of map.put.
Put method doesn't have three arguments; it's the original line breaks that make it look like it has three arguments .
There was a problem hiding this comment.
I have put the whole second argument in the next line as suggested, thank you for the info :)
|
@devCod3r import code style , https://eventmesh.apache.org/community/contribute/contribute |
…rotocolAdaptor] (apache#4270) * [ISSUE apache#4269] Used switch to replace the if-else. [MeshMessageProtocolAdaptor] * [ISSUE apache#4269] Used switch to replace the if-else. [MeshMessageProtocolAdaptor] * [ISSUE apache#4269] Used switch to replace the if-else. [MeshMessageProtocolAdaptor] * [ISSUE apache#4269] Used switch to replace the if-else. [MeshMessageProtocolAdaptor]
* feat: add redis connector. * feat: add redis connector. * feat: add redis connector. * feat: add redis connector. * feat: add redis connector. * [ISSUE #4023]Comparison using reference equality instead of value equality.[Operation] (#4276) * [ISSUE #4269] Used switch to replace the if-else. [MeshMessageProtocolAdaptor] (#4270) * [ISSUE #4269] Used switch to replace the if-else. [MeshMessageProtocolAdaptor] * [ISSUE #4269] Used switch to replace the if-else. [MeshMessageProtocolAdaptor] * [ISSUE #4269] Used switch to replace the if-else. [MeshMessageProtocolAdaptor] * [ISSUE #4269] Used switch to replace the if-else. [MeshMessageProtocolAdaptor] * [ISSUE #4099]Refactor re-used constant's usage from dedicated file (#4257) * [ISSUE #4099]: Refactor re-used constant's usage from dedicated file * [ISSUE #4099] Rename some constants for mongodb storage plugin * [ISSUE #4099] Refactor constant imports in mongodb cloud event util * [ISSUE #4099]: Replace contants imports to class import in mongo cloud event util * fix import order. * fix import order. * fix import order. * fix import order. --------- Co-authored-by: Fabian Bao <fabian.bao@agfa.com> Co-authored-by: kyooosukedn <87076947+kyooosukedn@users.noreply.github.com> Co-authored-by: Sam V Jose <124816912+devCod3r@users.noreply.github.com> Co-authored-by: ruhshan <ruhshan.ahmed@gmail.com>
…MessageProtocolAdaptor] (apache#4270)" This reverts commit 2cb5aa9.
…rotocolAdaptor] (apache#4270) * [ISSUE apache#4269] Used switch to replace the if-else. [MeshMessageProtocolAdaptor] * [ISSUE apache#4269] Used switch to replace the if-else. [MeshMessageProtocolAdaptor] * [ISSUE apache#4269] Used switch to replace the if-else. [MeshMessageProtocolAdaptor] * [ISSUE apache#4269] Used switch to replace the if-else. [MeshMessageProtocolAdaptor]
* feat: add redis connector. * feat: add redis connector. * feat: add redis connector. * feat: add redis connector. * feat: add redis connector. * [ISSUE apache#4023]Comparison using reference equality instead of value equality.[Operation] (apache#4276) * [ISSUE apache#4269] Used switch to replace the if-else. [MeshMessageProtocolAdaptor] (apache#4270) * [ISSUE apache#4269] Used switch to replace the if-else. [MeshMessageProtocolAdaptor] * [ISSUE apache#4269] Used switch to replace the if-else. [MeshMessageProtocolAdaptor] * [ISSUE apache#4269] Used switch to replace the if-else. [MeshMessageProtocolAdaptor] * [ISSUE apache#4269] Used switch to replace the if-else. [MeshMessageProtocolAdaptor] * [ISSUE apache#4099]Refactor re-used constant's usage from dedicated file (apache#4257) * [ISSUE apache#4099]: Refactor re-used constant's usage from dedicated file * [ISSUE apache#4099] Rename some constants for mongodb storage plugin * [ISSUE apache#4099] Refactor constant imports in mongodb cloud event util * [ISSUE apache#4099]: Replace contants imports to class import in mongo cloud event util * fix import order. * fix import order. * fix import order. * fix import order. --------- Co-authored-by: Fabian Bao <fabian.bao@agfa.com> Co-authored-by: kyooosukedn <87076947+kyooosukedn@users.noreply.github.com> Co-authored-by: Sam V Jose <124816912+devCod3r@users.noreply.github.com> Co-authored-by: ruhshan <ruhshan.ahmed@gmail.com>

Fixes #4269
Motivation
Replaced the if-else conditions with switch cases.
ISSUE #4269
Modifications
Describe the modifications you've done.
Replaced the if-else conditions with switch cases.
Documentation