Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iif expression (ternary) for (c)simple language #14888

Closed
wants to merge 3 commits into from

Conversation

ammachado
Copy link
Contributor

Description

This pull request adds a new expression to Simple language, IIF, which works as a ternary.

Target

  • I checked that the commit is targeting the correct branch (note that Camel 3 uses camel-3.x, whereas Camel 4 uses the main branch)

Tracking

  • If this is a large change, bug fix, or code improvement, I checked there is a JIRA issue filed for the change (usually before you start working on it).

Apache Camel coding standards and style

  • I checked that each commit in the pull request has a meaningful subject line and body.
  • I have run mvn clean install -DskipTests locally and I have committed all auto-generated changes

Copy link
Contributor

🌟 Thank you for your contribution to the Apache Camel project! 🌟

🤖 CI automation will test this PR automatically.

🐫 Apache Camel Committers, please review the following items:

  • First-time contributors require MANUAL approval for the GitHub Actions to run

  • You can use the command /component-test (camel-)component-name1 (camel-)component-name2.. to request a test from the test bot.

  • You can label PRs using build-all, build-dependents, skip-tests and test-dependents to fine-tune the checks executed by this PR.

  • Build and test logs are available in the Summary page. Only Apache Camel committers have access to the summary.

  • ⚠️ Be careful when sharing logs. Review their contents before sharing them publicly.

@ammachado ammachado changed the title Iif expression (ternary) for (c)simple language iif expression (ternary) for (c)simple language Jul 21, 2024
Copy link
Contributor

@gnodet gnodet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few javadoc improvements and this empty method which needs to be removed I think.

@ammachado ammachado requested a review from gnodet August 1, 2024 03:48
@davsclaus
Copy link
Contributor

Oh the simple language is as its name intended for simpler programming. We do not have control loops in the language, so adding iif when there is no if is a bit strange.

I guess the java standard with ? and : is tricky, and there is no grammar files for simple.

How often do you need this and do you have real-world use-cases where it would be good to have.

The groovy language is already support and works great for more power.

@ammachado
Copy link
Contributor Author

I'm proposing this change because I've been working with a lot of projects that are using the Choice DSL to set headers/properties variables on a ternary-like fashion. Refactoring the choice block as a Groovy expression is definitely an option, but I was looking for a solution that did not requires extra dependencies.

@davsclaus
Copy link
Contributor

@davsclaus
Copy link
Contributor

Okay I created a ticket - its good to have this functionality (see JIRA)

@davsclaus
Copy link
Contributor

Replaced by new PR: #15168

@davsclaus davsclaus closed this Aug 15, 2024
@ammachado ammachado deleted the iif-expression branch August 21, 2024 20:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants