AutoRefactor icon indicating copy to clipboard operation
AutoRefactor copied to clipboard

Investigate refactorings for Java 1.8

Open JnRouvignac opened this issue 12 years ago • 3 comments

#See http://www.techempower.com/blog/2013/03/26/everything-about-java-8/ :

  • interfaces with static methods and default method implementations.
  • instantiate @FunctionalInterface with lambdas, - automatically convert code to do it
    • use of methods references to do this
  • Add @FunctionalInterface to single method interfaces
  • Generic type inference improvements - remove more types
  • Collections API additions - big opportunity here!!
    • Ex: Collection.removeIf() is O(n) for ArrayList rather than O(n2)
    • Ex: static Collections.sort(list, comparator) => List.sort(Comparator)
    • Ex: Map.computeIfAbsent() to simplify MultiMap usage
    • See Collections Refueled talk at JavaOne 2016
  • java.util.function - can anything be done automatically here?
  • java.util.stream - can anything be done automatically here?
  • java.time - can anything be done automatically here?
    • See http://stackoverflow.com/questions/19431234/converting-between-java-time-localdatetime-and-java-util-date
    • and http://blog.progs.be/542/date-to-java-time
  • Reflection and annotation changes - can anything be done automatically here?
  • doclint - fix javadocs automatically
  • java.util.Optional - can anything be done automatically here?
  • newer helper methods: static methods on Comparator (ex: comparingInt()), Objects::nonNull(), etc.
  • Other miscellaneous additions to java.lang, java.util, and elsewhere - can anything be done automatically here?
  • From SonarQube:

Also see https://blog.jetbrains.com/upsource/2016/08/03/what-to-look-for-in-java-8-code/

JnRouvignac avatar Apr 26 '13 15:04 JnRouvignac

Functions allow to easily build Comparators with https://docs.oracle.com/javase/8/docs/api/java/util/Comparator.html#comparing-java.util.function.Function-

JnRouvignac avatar Nov 09 '14 16:11 JnRouvignac

  • String.chars()
  • StringJoiner and String.join()
  • Path.lines()
  • Path.walk()
  • Collection.removeIf()
  • Comparators. comparing().thenComparing()
  • New methods on List, Map, ConcurrentMap, etc.
  • AtomicLong.updateAndGet()
  • AtomicLong.accumulateAndGet()

JnRouvignac avatar Feb 20 '15 17:02 JnRouvignac

Refactoring loops into collection pipelines: http://martinfowler.com/articles/refactoring-pipelines.html

JnRouvignac avatar Jun 30 '15 16:06 JnRouvignac