Reputation: 7
stageIndexingCode = StringUtils.isEmpty(indexOperation)
? stageIndexingCode
: indexOperation;
How can we rewrite this into if else structure? without creating any warnings.
Note: stageIndexingCode
is of type String
Upvotes: 0
Views: 2396
Reputation: 3691
You should make some research about what is a ternary operator.
if (StringUtils.isEmpty(indexOperation)) {
stageIndexingCode = stageIndexingCode;
} else {
stageIndexingCode =indexOperation;
}
shorter form:
if (!StringUtils.isEmpty(indexOperation)) {
stageIndexingCode =indexOperation;
}
Upvotes: 1