How can I automatically replace the ternary operator by if/else?

Sometimes I get some very ugly code which uses the ternary operator too often. I would like to be able to detect such ternary operators:

statement ? if-block : else-block;

and replace them by

if (statement) {
    if-block
} else {
    else-block
}

If solution should work with Java.

Answers


Need Your Help

Cross browser paste capture - Mac Opera issues

javascript jquery opera copy-paste

I'm working on a cross browser paste capture. I've got this working & tested in Chrome and Firefox (on a mac). It should work on Chrome and Firefox on a PC as well but I have not had a chance t...

Aspect oriented programming and/or Enterprise Library 5.0 for Logging/Exception implementation?

logging exception-handling aop enterprise-library-5

I can implement both AOP (using Postsharp) and the EntLib (v5.0) for cross cutting concerns as logging and exception handling/strategies.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.