Main
Main copied to clipboard
Java8 Tippers- from IntelliJ
Part II of #1085
-
Anonymous type can be replaced with lambda:
-
putIfAbsent: (had that one already, but without checking the type is Map)
if (stats.get(key) == null)
stats.put(key, new RealStatistics());
- for loop replaceable with foreach:
for (int ¢ = 0; ¢ < modifiers.size(); ++¢)
if (modifiers.get(¢) instanceof MarkerAnnotation && (modifiers.get(¢) + "").contains("@Test") && (modifiers.get(¢) + "").contains("@Test"))
return true;
to
for (Object modifier : modifiers)
if (modifier instanceof MarkerAnnotation && (modifier + "").contains("@Test") && (modifier + "").contains("@Test"))
return true;
- for loop can be collapsed with stream API: (Have a Nanos for that - ForEach, ForEachFiltered) (a) foreach
for (final List<Tipper<? extends ASTNode>> ¢ : implementation)
if (¢ != null)
disable(c, ¢);
to
implementation.stream().filter(¢ -> ¢ != null).forEach((final List<Tipper<? extends ASTNode>> ¢) -> disable(c, ¢));
(b)collect
final List<Expression> operands = new ArrayList<>();
for (final Expression ¢ : hop.operands(flatten.of($)))
operands.add(make.notOf(¢));
to
final List<Expression> operands = hop.operands(flatten.of($)).stream().map(make::notOf).collect(Collectors.toList());
- Lambda can be replaced with method reference:
ReportGenerator.write(input, output, "δ ", (n1, n2) -> system.d(n1, n2));
to
ReportGenerator.write(input, output, "δ ", system::d);
xs.stream().map(¢ -> az.stringLiteral(¢).getLiteralValue()).toArray(n -> new String[n])
to
xs.stream().map(¢ -> az.stringLiteral(¢).getLiteralValue()).toArray(String[]::new);
-
Unnecessary Boxing.
-
Unnecessary Unboxing.