@@ -325,10 +325,6 @@ protected InstanceKey computeInstanceKey(Collection<InstanceKey> trackedInstance
325
325
"Can't find instance key for: " + this .getCreation () + " using tracked instances: " + trackedInstances );
326
326
}
327
327
328
- protected void convertToParallel (CompilationUnitRewrite rewrite ) {
329
- convert ("sequential" , "parallel" , "stream" , "parallelStream" , rewrite );
330
- }
331
-
332
328
private void convert (String source , String target , String sourceGenerator , String targetGenerator ,
333
329
CompilationUnitRewrite rewrite ) {
334
330
MethodInvocation creation = this .getCreation ();
@@ -348,36 +344,38 @@ private void convert(String source, String target, String sourceGenerator, Strin
348
344
349
345
String identifier = inv .getName ().getIdentifier ();
350
346
351
- if (identifier .equals (source )) {
347
+ if (identifier .equals (source ))
352
348
// remove it.
353
349
astRewrite .replace (inv , inv .getExpression (), null );
354
- } else if (identifier .equals (target )) {
350
+ else if (identifier .equals (target ))
355
351
done = true ;
356
- } else if (identifier .equals (sourceGenerator )) {
352
+ else if (identifier .equals (sourceGenerator )) {
357
353
// Replace with parallelStream().
358
354
SimpleName newMethodName = ast .newSimpleName (targetGenerator );
359
355
astRewrite .replace (creation .getName (), newMethodName , null );
360
- } else if (identifier .equals (targetGenerator )) {
356
+ } else if (identifier .equals (targetGenerator ))
361
357
done = true ;
362
- } else {
363
- // if we're at the end.
364
- if (inv .getExpression ().getNodeType () != ASTNode .METHOD_INVOCATION
365
- || inv .getExpression ().getNodeType () == ASTNode .METHOD_INVOCATION
366
- && !implementsBaseStream (inv .getExpression ().resolveTypeBinding ())) {
367
- MethodInvocation newMethodInvocation = ast .newMethodInvocation ();
368
- newMethodInvocation .setName (ast .newSimpleName (target ));
369
- MethodInvocation invCopy = (MethodInvocation ) ASTNode .copySubtree (ast , inv );
370
- newMethodInvocation .setExpression (invCopy );
371
- astRewrite .replace (inv , newMethodInvocation , null );
372
- }
358
+ else // if we're at the end.
359
+ if (inv .getExpression ().getNodeType () != ASTNode .METHOD_INVOCATION
360
+ || inv .getExpression ().getNodeType () == ASTNode .METHOD_INVOCATION
361
+ && !implementsBaseStream (inv .getExpression ().resolveTypeBinding ())) {
362
+ MethodInvocation newMethodInvocation = ast .newMethodInvocation ();
363
+ newMethodInvocation .setName (ast .newSimpleName (target ));
364
+ MethodInvocation invCopy = (MethodInvocation ) ASTNode .copySubtree (ast , inv );
365
+ newMethodInvocation .setExpression (invCopy );
366
+ astRewrite .replace (inv , newMethodInvocation , null );
373
367
}
374
368
expression = inv .getExpression ();
375
369
} else
376
370
done = true ;
377
371
}
378
372
373
+ protected void convertToParallel (CompilationUnitRewrite rewrite ) {
374
+ this .convert ("sequential" , "parallel" , "stream" , "parallelStream" , rewrite );
375
+ }
376
+
379
377
protected void convertToSequential (CompilationUnitRewrite rewrite ) {
380
- convert ("parallel" , "sequential" , "parallelStream" , "stream" , rewrite );
378
+ this . convert ("parallel" , "sequential" , "parallelStream" , "stream" , rewrite );
381
379
}
382
380
383
381
public Set <TransformationAction > getActions () {
0 commit comments