Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package p;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import edu.cuny.hunter.streamrefactoring.annotations.*;
import p.A.Widget.Color;

public class A {

static class Widget {
enum Color {
RED, BLUE, GREEN, PINK, ORANGE, YELLOW
};

public Color getColor() {
return this.getColor();
}
}

/**
* P6 in table 3
*/
@EntryPoint
void m() {
Collection<Widget> orderedWidgets = new ArrayList<>();
Map<Color, List<Widget>> widgetsByColor = orderedWidgets.stream()
.collect(Collectors.groupingByConcurrent(Widget::getColor));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package p;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import edu.cuny.hunter.streamrefactoring.annotations.*;
import p.A.Widget.Color;

public class A {

static class Widget {
enum Color {
RED, BLUE, GREEN, PINK, ORANGE, YELLOW
};

public Color getColor() {
return this.getColor();
}
}

/**
* P7 in table 3
*/
@EntryPoint
void m() {
Collection<Widget> orderedWidgets = new ArrayList<>();
Map<Color, List<Widget>> widgetsByColor = orderedWidgets.parallelStream()
.collect(Collectors.groupingBy(Widget::getColor));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package p;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import edu.cuny.hunter.streamrefactoring.annotations.*;
import p.A.Widget.Color;

public class A {

static class Widget {
enum Color {
RED, BLUE, GREEN, PINK, ORANGE, YELLOW
};

public Color getColor() {
return this.getColor();
}
}

/**
* P8 in table 3
*/
@EntryPoint
void m() {
Collection<Widget> orderedWidgets = new ArrayList<>();
Map<Color, List<Widget>> widgetsByColor = orderedWidgets.parallelStream()
.collect(Collectors.groupingByConcurrent(Widget::getColor));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package p;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;

import edu.cuny.hunter.streamrefactoring.annotations.*;
import p.A.Widget.Color;

public class A {

static class Widget {
enum Color {
RED, BLUE, GREEN, PINK, ORANGE, YELLOW
};

public Color getColor() {
return this.getColor();
}
}

/**
* P9 in table 3
*/
@EntryPoint
void m() {
Collection<Widget> orderedWidgets = new ArrayList<>();
Map<Color, Set<Widget>> widgetsByColor = orderedWidgets.stream()
.collect(Collectors.groupingBy(Widget::getColor, HashMap::new, Collectors.toSet()));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package p;

import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;

import edu.cuny.hunter.streamrefactoring.annotations.*;
import p.A.Widget.Color;

public class A {

static class Widget {
enum Color {
RED, BLUE, GREEN, PINK, ORANGE, YELLOW
};

public Color getColor() {
return this.getColor();
}
}

/**
* P10 in table 3
*/
@EntryPoint
void m() {
Collection<Widget> orderedWidgets = new ArrayList<>();
Map<Color, Set<Widget>> widgetsByColor = orderedWidgets.stream().collect(Collectors.groupingByConcurrent(
Widget::getColor, ConcurrentHashMap::new, Collectors.toCollection(LinkedHashSet::new)));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package p;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;

import edu.cuny.hunter.streamrefactoring.annotations.*;
import p.A.Widget.Color;

public class A {

static class Widget {
enum Color {
RED, BLUE, GREEN, PINK, ORANGE, YELLOW
};

public Color getColor() {
return this.getColor();
}
}

/**
* P11 in table 3
*/
@EntryPoint
void m() {
Collection<Widget> orderedWidgets = new ArrayList<>();
Map<Color, Set<Widget>> widgetsByColor = orderedWidgets.parallelStream()
.collect(Collectors.groupingBy(Widget::getColor, HashMap::new, Collectors.toSet()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
import org.eclipse.jdt.ui.tests.refactoring.Java18Setup;
import org.eclipse.jdt.ui.tests.refactoring.RefactoringTest;
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
import org.junit.Rule;
import org.junit.rules.ExpectedException;

import edu.cuny.hunter.streamrefactoring.core.analysis.ExecutionMode;
import edu.cuny.hunter.streamrefactoring.core.analysis.Ordering;
Expand Down Expand Up @@ -704,4 +706,49 @@ public void testField() throws Exception {
false, EnumSet.of(TransformationAction.CONVERT_TO_PARALLEL), PreconditionSuccess.P1,
Refactoring.CONVERT_SEQUENTIAL_STREAM_TO_PARALLEL, RefactoringStatus.OK, Collections.emptySet()));
}

/**
* Test #64. Test concurrent reductions.
*/
@Rule
public ExpectedException thrown = ExpectedException.none();

public void testConcurrentReduction() throws Exception {
thrown.expect(NullPointerException.class);
}

/**
* Test #64. Test concurrent reductions.
*/
public void testConcurrentReduction1() throws Exception {
thrown.expect(NullPointerException.class);
}

/**
* Test #64. Test concurrent reductions.
*/
public void testConcurrentReduction2() throws Exception {
thrown.expect(NullPointerException.class);
}

/**
* Test #64. Test concurrent reductions.
*/
public void testConcurrentReduction3() throws Exception {
thrown.expect(NullPointerException.class);
}

/**
* Test #64. Test concurrent reductions.
*/
public void testConcurrentReduction4() throws Exception {
thrown.expect(NullPointerException.class);
}
/**
* Test #64. Test concurrent reductions.
*/
public void testConcurrentReduction5() throws Exception {
thrown.expect(NullPointerException.class);
}

}