heisenbergs-uncertainty opened a new pull request, #3640:
URL: https://github.com/apache/streampipes/pull/3640

   <!--
     ~ Licensed to the Apache Software Foundation (ASF) under one or more
     ~ contributor license agreements.  See the NOTICE file distributed with
     ~ this work for additional information regarding copyright ownership.
     ~ The ASF licenses this file to You under the Apache License, Version 2.0
     ~ (the "License"); you may not use this file except in compliance with
     ~ the License.  You may obtain a copy of the License at
     ~
     ~    http://www.apache.org/licenses/LICENSE-2.0
     ~
     ~ Unless required by applicable law or agreed to in writing, software
     ~ distributed under the License is distributed on an "AS IS" BASIS,
     ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     ~ See the License for the specific language governing permissions and
     ~ limitations under the License.
     ~
     -->
   
     <!--
   Thanks for contributing! Here are some tips you can follow to help us 
incorporate your contribution quickly and easily:
   1. If this is your first time, please read our contributor guidelines:
       - https://streampipes.apache.org/community/get-involved/
       - https://cwiki.apache.org/confluence/display/STREAMPIPES/Getting+Started
   2. Make sure the PR title is formatted like: `[#<GitHub issue id>] PR title 
...`
   3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., 
`[WIP][#<GitHub issue id>] PR title ...`.
   4. Please write your PR title to summarize what this PR proposes/fixes.
   5. Link the PR to the corresponding GitHub issue (if present) in the 
`Development` section in the right menu bar.
   6. Be sure to keep the PR description updated to reflect all changes.
   7. If possible, provide a concise example to reproduce the issue for a 
faster review.
   8. Make sure tests pass via `mvn clean install`.
   9. (Optional) If the contribution is large, please file an Apache ICLA
       - http://apache.org/licenses/icla.pdf
   -->
   
   ### Purpose
   <!--
   Please clarify what changes you are proposing and describe how those changes 
will address the issue.
   Furthermore, describe potential consequences the changes might have.
   -->
   Introduce Pipeline Element Processors that allow a user to implement the 
"Switch" operator. I have often found myself wanting to setup a pipeline that 
uses the "Switch" operator but have had to use a complicated set of boolean 
conditions to try and implement it or I eventually end up just using a 
JavaScript processor to use the switch statement. The processors reflect the 
following block.
   
   ```java
   switch(String x) {
     case "test":
      do something;
      break;
     case "test 2":
      do something else;
      break;
     default:
      do this if nothing else works;
      break;
   }
   ```
   
   The proposed updates introduce three processors, each which have the purpose 
of handling a different input type. I have implemented a Boolean Input 
processor, String input processor, and Numerical input processor. This is done 
primarily for the sake of cleaner code along with simplifying the detection of 
the incoming event property. These three processors could be combined into one 
"Switch Operator Processor" if there was the introduction of some "Conditional 
Requirements" component.
   
   
![image](https://github.com/user-attachments/assets/161d9c80-7848-49c8-b6d4-7fe003b70781)
   
   
![image](https://github.com/user-attachments/assets/5fe43290-14fd-4750-a680-9a3eae494ba6)
   
   
![image](https://github.com/user-attachments/assets/bd256fa0-c162-4ab5-9b68-da5557f8e7be)
   
   
![image](https://github.com/user-attachments/assets/c7478af1-e6fa-4e10-a174-c10c7ffd6db5)
   
   ### Remarks
   <!--
   Is there anything left we need to pay attention on?
   Are there some references that might be important? E.g. links to Confluence, 
or discussions
   on the mailing list or GitHub.
   -->
   
   I have written unit tests for the numerical processor locally but ran into 
issues when I transferred the updates from my custom extensions repo to the 
main streampipes codebase. If someone has input on the right way to write tests 
for streampipes or would like to write the unit tests themselves that would be 
welcome.
   
   PR introduces (a) breaking change(s): no
   PR introduces (a) deprecation(s): no
   


-- 
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]

Reply via email to