[
https://issues.apache.org/jira/browse/NIFI-3206?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15754898#comment-15754898
]
ASF GitHub Bot commented on NIFI-3206:
--------------------------------------
Github user JPercivall commented on a diff in the pull request:
https://github.com/apache/nifi/pull/1333#discussion_r92842330
--- Diff: nifi-docs/src/main/asciidoc/expression-language-guide.adoc ---
@@ -963,6 +963,36 @@ Expressions will provide the following results:
will return 0.
+[.function]
+=== ifElse
+
+*Description*: [.description]#Evaluates the first argument if the Subject
evaluates to true, or the second argument
+if the Subject evaluates to false.#
+
+*Subject Type*: [.subject]#Boolean#
+
+*Arguments*:
+
+ - [.argName]#_EvaluateIfTrue_# : [.argDesc]#The value to return if the
Subject is true#
+ - [.argName]#_EvaluateIfFalse_# : [.argDesc]#The value to return if the
Subject is false#
+
+*Return Type*: [.returnType]#String#
+
+*Examples*: If the "filename" attribute has the value "a brand new
filename.txt", the "nullFilename" attribute has
+the value null, and the "bool" attribute has the value "true", then the
following expressions will provide
+the following results:
+
+
+
+.ifElse Examples
+|===================================================================
+| Expression | Value
+| `${filename:ifElse('found', 'not_found')}` | `found`
--- End diff --
Actually this will not return 'found' because when the String is converted
to a boolean it is only true if it is equalsIgnoreCase to "true".
> Add ifElse function to Expression Language
> ------------------------------------------
>
> Key: NIFI-3206
> URL: https://issues.apache.org/jira/browse/NIFI-3206
> Project: Apache NiFi
> Issue Type: Improvement
> Reporter: Matt Burgess
> Assignee: Matt Burgess
>
> Although UpdateAttribute's Advanced tab lets the user perform conditional
> processing (if-else, e.g.), it would be nice to allow for simple conditionals
> wherever Expression Language is supported.
> For example, in any EL-supported property, I could specify (with an attribute
> "filename" for example):
> ${filename:isNull():ifElse('not_found', 'found')}
> Then if filename is null this will evaluate to 'not_found', and if it is
> non-null it would evaluate to 'found'. For consistency the subject should be
> allowed to be anything that can be evaluated as a boolean, so if "myVal" is
> set to the string "true", then:
> ${myVal:ifElse('a', 'b')}
> should evaluate to 'a'
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)