title: Automatic code simplification via refactoring
body: <p>Is there a tool for automatic java code simplification via refactoring?</p>
  
  <p>There are such tools for Python and C:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/14517524/automatically-simplifying-refactoring-python-code-e-g-for-loops-list-compre">Automatically simplifying/refactoring Python code (e.g. for loops -&gt; list comprehension)?</a></li>
  <li><a href="https://stackoverflow.com/questions/7259494/is-there-a-tool-to-test-the-conciseness-of-c-program/7259905#7259905">Is there a tool to test the conciseness of c program?</a>) </li>
  </ul>
  
  <p>but I'm not aware of any such program for Java.</p>
  
  <p>There are many cases where a tool could automatically simplify code, like e.g.:</p>
  
  <ul>
  <li>loops: <code>for (String s: a) { b.add(s); }</code> → <code>b.addAll(a);</code></li>
  <li>if/return: <code>if (x) return true; else return false;</code> → <code>return x;</code></li>
  <li>ternary operator: <code>if (x) {result = a;} else {result = b;}</code> → <code>result = x ? a : b;</code></li>
  <li>automatic refactor to diamond operator / exception multi catch / lambdas</li>
  <li>lots more...</li>
  </ul>
  
  <p>The advantage of such automatic refactor is removal of lots of boilerplate lines of code, making it more clean and conceise.</p>