Skip to content

Commit a97586c

Browse files
author
jodzga
committed
Unified code formatting.
1 parent fd044bd commit a97586c

File tree

222 files changed

+2773
-4657
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

222 files changed

+2773
-4657
lines changed

example/com/linkedin/parseq/example/collections/FParFilterExample.java

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,29 +14,25 @@
1414
import com.linkedin.parseq.example.common.ExampleUtil;
1515
import com.linkedin.parseq.example.common.MockService;
1616

17+
1718
/**
1819
* @author Jaroslaw Odzga (jodzga@linkedin.com)
1920
*/
20-
public class FParFilterExample extends AbstractExample
21-
{
22-
public static void main(String[] args) throws Exception
23-
{
21+
public class FParFilterExample extends AbstractExample {
22+
public static void main(String[] args) throws Exception {
2423
new FParFilterExample().runExample();
2524
}
2625

2726
@Override
28-
protected void doRunExample(final Engine engine) throws Exception
29-
{
27+
protected void doRunExample(final Engine engine) throws Exception {
3028
final MockService<String> httpClient = getService();
3129
List<String> urls = Arrays.asList("http://www.linkedin.com", "http://www.google.com", "http://www.twitter.com");
3230

3331
Task<String> find =
3432
ParSeqCollection.fromValues(urls)
35-
.mapTask(url -> fetchUrl(httpClient, url)
36-
.withTimeout(200, TimeUnit.MILLISECONDS)
37-
.recover("default", t -> ""))
38-
.filter(s -> s.contains("google"))
39-
.find(s -> s.contains("google"));
33+
.mapTask(
34+
url -> fetchUrl(httpClient, url).withTimeout(200, TimeUnit.MILLISECONDS).recover("default", t -> ""))
35+
.filter(s -> s.contains("google")).find(s -> s.contains("google"));
4036

4137
engine.run(find);
4238

example/com/linkedin/parseq/example/collections/GroupByExample.java

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,29 +10,27 @@
1010
import com.linkedin.parseq.example.common.ExampleUtil;
1111
import com.linkedin.parseq.example.common.MockService;
1212

13+
1314
/**
1415
* @author Jaroslaw Odzga (jodzga@linkedin.com)
1516
*/
16-
public class GroupByExample extends AbstractExample
17-
{
18-
public static void main(String[] args) throws Exception
19-
{
17+
public class GroupByExample extends AbstractExample {
18+
public static void main(String[] args) throws Exception {
2019
new GroupByExample().runExample();
2120
}
2221

2322
@Override
24-
protected void doRunExample(final Engine engine) throws Exception
25-
{
23+
protected void doRunExample(final Engine engine) throws Exception {
2624
final MockService<String> httpClient = getService();
2725
List<String> urls = Arrays.asList("http://www.linkedin.com", "http://www.google.com", "http://www.twitter.com",
2826
"http://www.linkedin.com", "http://www.google.com", "http://www.linkedin.com");
2927

3028
Task<String> result = null;
31-
// Collections.fromIterable(urls)
32-
// .par(url -> fetchUrl(httpClient, url))
33-
// .groupBy(i -> i)
34-
// .map(group -> "group: " + group.getKey() + ", count: " + group.count())
35-
// .reduce((a, b) -> a + "\n" + b );
29+
// Collections.fromIterable(urls)
30+
// .par(url -> fetchUrl(httpClient, url))
31+
// .groupBy(i -> i)
32+
// .map(group -> "group: " + group.getKey() + ", count: " + group.count())
33+
// .reduce((a, b) -> a + "\n" + b );
3634

3735
engine.run(result);
3836

example/com/linkedin/parseq/example/collections/MaxCollectionExample.java

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,20 @@
1111
import com.linkedin.parseq.example.common.AbstractExample;
1212
import com.linkedin.parseq.example.common.ExampleUtil;
1313

14+
1415
/**
1516
* @author Jaroslaw Odzga (jodzga@linkedin.com)
1617
*/
17-
public class MaxCollectionExample extends AbstractExample
18-
{
19-
public static void main(String[] args) throws Exception
20-
{
18+
public class MaxCollectionExample extends AbstractExample {
19+
public static void main(String[] args) throws Exception {
2120
new MaxCollectionExample().runExample();
2221
}
2322

2423
@Override
25-
protected void doRunExample(final Engine engine) throws Exception
26-
{
24+
protected void doRunExample(final Engine engine) throws Exception {
2725
List<String> urls = Arrays.asList("http://www.linkedin.com", "http://www.google.com", "http://www.twitter.com");
2826

29-
30-
Task<String> task = ParSeqCollection.fromValues(urls)
31-
.max(Comparator.naturalOrder())
32-
.andThen(System.out::println);
27+
Task<String> task = ParSeqCollection.fromValues(urls).max(Comparator.naturalOrder()).andThen(System.out::println);
3328

3429
engine.run(task);
3530

example/com/linkedin/parseq/example/collections/ParFilterExample.java

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,30 +15,25 @@
1515
import com.linkedin.parseq.example.common.ExampleUtil;
1616
import com.linkedin.parseq.example.common.MockService;
1717

18+
1819
/**
1920
* @author Jaroslaw Odzga (jodzga@linkedin.com)
2021
*/
21-
public class ParFilterExample extends AbstractExample
22-
{
23-
public static void main(String[] args) throws Exception
24-
{
22+
public class ParFilterExample extends AbstractExample {
23+
public static void main(String[] args) throws Exception {
2524
new ParFilterExample().runExample();
2625
}
2726

2827
@Override
29-
protected void doRunExample(final Engine engine) throws Exception
30-
{
28+
protected void doRunExample(final Engine engine) throws Exception {
3129
final MockService<String> httpClient = getService();
3230
List<String> urls = Arrays.asList("http://www.linkedin.com", "http://www.google.com", "http://www.twitter.com");
3331

3432
List<Task<String>> fetchSizes = fetchList(httpClient, urls);
3533

36-
Task<String> find =
37-
ParSeqCollection.fromTasks(fetchSizes)
38-
.filter(s -> !s.contains("google"))
39-
.flatMap(z -> ParSeqCollection.fromTasks(fetchList(httpClient, urls))
40-
.filter(s -> s.contains("twitter")))
41-
.find(s -> s.contains("twitter"));
34+
Task<String> find = ParSeqCollection.fromTasks(fetchSizes).filter(s -> !s.contains("google"))
35+
.flatMap(z -> ParSeqCollection.fromTasks(fetchList(httpClient, urls)).filter(s -> s.contains("twitter")))
36+
.find(s -> s.contains("twitter"));
4237

4338
engine.run(find);
4439

@@ -50,12 +45,8 @@ protected void doRunExample(final Engine engine) throws Exception
5045
}
5146

5247
private List<Task<String>> fetchList(final MockService<String> httpClient, List<String> urls) {
53-
List<Task<String>> fetchSizes =
54-
urls.stream()
55-
.map(url ->
56-
fetchUrl(httpClient, url)
57-
.withTimeout(200, TimeUnit.MILLISECONDS)
58-
.recover("default", t -> ""))
48+
List<Task<String>> fetchSizes = urls.stream()
49+
.map(url -> fetchUrl(httpClient, url).withTimeout(200, TimeUnit.MILLISECONDS).recover("default", t -> ""))
5950
.collect(Collectors.toList());
6051
return fetchSizes;
6152
}

example/com/linkedin/parseq/example/collections/ParFindExample.java

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,30 +15,25 @@
1515
import com.linkedin.parseq.example.common.ExampleUtil;
1616
import com.linkedin.parseq.example.common.MockService;
1717

18+
1819
/**
1920
* @author Jaroslaw Odzga (jodzga@linkedin.com)
2021
*/
21-
public class ParFindExample extends AbstractExample
22-
{
23-
public static void main(String[] args) throws Exception
24-
{
22+
public class ParFindExample extends AbstractExample {
23+
public static void main(String[] args) throws Exception {
2524
new ParFindExample().runExample();
2625
}
2726

2827
@Override
29-
protected void doRunExample(final Engine engine) throws Exception
30-
{
28+
protected void doRunExample(final Engine engine) throws Exception {
3129
final MockService<String> httpClient = getService();
3230
List<String> urls = Arrays.asList("http://www.linkedin.com", "http://www.google.com", "http://www.twitter.com");
3331

3432
List<Task<String>> fetchSizes = fetchList(httpClient, urls);
3533

36-
Task<String> find =
37-
ParSeqCollection.fromTasks(fetchSizes)
38-
.filter(s -> s.contains("twitter"))
39-
.mapTask(z -> ParSeqCollection.fromTasks(fetchList(httpClient, urls))
40-
.find(s -> s.contains("linkedin")))
41-
.first();
34+
Task<String> find = ParSeqCollection.fromTasks(fetchSizes).filter(s -> s.contains("twitter"))
35+
.mapTask(z -> ParSeqCollection.fromTasks(fetchList(httpClient, urls)).find(s -> s.contains("linkedin")))
36+
.first();
4237

4338
engine.run(find);
4439

@@ -50,12 +45,8 @@ protected void doRunExample(final Engine engine) throws Exception
5045
}
5146

5247
private List<Task<String>> fetchList(final MockService<String> httpClient, List<String> urls) {
53-
List<Task<String>> fetchSizes =
54-
urls.stream()
55-
.map(url ->
56-
fetchUrl(httpClient, url)
57-
.withTimeout(200, TimeUnit.MILLISECONDS)
58-
.recover("default", t -> ""))
48+
List<Task<String>> fetchSizes = urls.stream()
49+
.map(url -> fetchUrl(httpClient, url).withTimeout(200, TimeUnit.MILLISECONDS).recover("default", t -> ""))
5950
.collect(Collectors.toList());
6051
return fetchSizes;
6152
}

example/com/linkedin/parseq/example/collections/SortedCollectionExample.java

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,21 @@
1111
import com.linkedin.parseq.example.common.AbstractExample;
1212
import com.linkedin.parseq.example.common.ExampleUtil;
1313

14+
1415
/**
1516
* @author Jaroslaw Odzga (jodzga@linkedin.com)
1617
*/
17-
public class SortedCollectionExample extends AbstractExample
18-
{
19-
public static void main(String[] args) throws Exception
20-
{
18+
public class SortedCollectionExample extends AbstractExample {
19+
public static void main(String[] args) throws Exception {
2120
new SortedCollectionExample().runExample();
2221
}
2322

2423
@Override
25-
protected void doRunExample(final Engine engine) throws Exception
26-
{
24+
protected void doRunExample(final Engine engine) throws Exception {
2725
List<Integer> numbers = Arrays.asList(10, 20, 5, 8, 21, 14);
2826

29-
30-
Task<?> task = ParSeqCollection.fromValues(numbers)
31-
.sorted(Comparator.naturalOrder())
32-
.toList()
33-
.andThen(System.out::println);
27+
Task<?> task =
28+
ParSeqCollection.fromValues(numbers).sorted(Comparator.naturalOrder()).toList().andThen(System.out::println);
3429

3530
engine.run(task);
3631

example/com/linkedin/parseq/example/collections/StreamExample.java

Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -15,48 +15,44 @@
1515
import com.linkedin.parseq.example.common.ExampleUtil;
1616
import com.linkedin.parseq.example.common.MockService;
1717

18+
1819
/**
1920
* @author Jaroslaw Odzga (jodzga@linkedin.com)
2021
*/
21-
public class StreamExample extends AbstractExample
22-
{
23-
public static void main(String[] args) throws Exception
24-
{
22+
public class StreamExample extends AbstractExample {
23+
public static void main(String[] args) throws Exception {
2524
new StreamExample().runExample();
2625
}
2726

28-
static final List<String> urls = Arrays.asList("http://www.linkedin.com", "http://www.google.com", "http://www.twitter.com");
27+
static final List<String> urls =
28+
Arrays.asList("http://www.linkedin.com", "http://www.google.com", "http://www.twitter.com");
2929
static final List<String> paths = Arrays.asList("/p1", "/p2");
3030

3131
@Override
32-
protected void doRunExample(final Engine engine) throws Exception
33-
{
32+
protected void doRunExample(final Engine engine) throws Exception {
3433
final MockService<String> httpClient = getService();
3534

36-
Task<?> task = ParSeqCollection.fromValues(urls)
37-
.flatMap(base -> ParSeqCollection.fromValues(paths)
38-
.map(path -> base + path)
39-
.mapTask(url -> fetchUrl(httpClient, url)))
40-
.subscribe(new Subscriber<String>() {
41-
42-
@Override
43-
public void onSubscribe(Subscription subscription) {
44-
}
35+
Task<?> task = ParSeqCollection.fromValues(urls).flatMap(
36+
base -> ParSeqCollection.fromValues(paths).map(path -> base + path).mapTask(url -> fetchUrl(httpClient, url)))
37+
.subscribe(new Subscriber<String>() {
4538

46-
@Override
47-
public void onNext(String element) {
48-
System.out.println(element);
49-
}
39+
@Override
40+
public void onSubscribe(Subscription subscription) {
41+
}
5042

51-
@Override
52-
public void onError(Throwable cause) {
53-
}
43+
@Override
44+
public void onNext(String element) {
45+
System.out.println(element);
46+
}
5447

55-
@Override
56-
public void onComplete() {
57-
}
58-
});
48+
@Override
49+
public void onError(Throwable cause) {
50+
}
5951

52+
@Override
53+
public void onComplete() {
54+
}
55+
});
6056

6157
engine.run(task);
6258

example/com/linkedin/parseq/example/collections/SumExample.java

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,32 +11,26 @@
1111
import com.linkedin.parseq.example.common.AbstractExample;
1212
import com.linkedin.parseq.example.common.ExampleUtil;
1313

14+
1415
/**
1516
* @author Jaroslaw Odzga (jodzga@linkedin.com)
1617
*/
17-
public class SumExample extends AbstractExample
18-
{
19-
public static void main(String[] args) throws Exception
20-
{
18+
public class SumExample extends AbstractExample {
19+
public static void main(String[] args) throws Exception {
2120
new SumExample().runExample();
2221
}
2322

2423
static final List<Integer> numbers = Arrays.asList(1, 2, 3);
2524

2625
static Task<Integer> toTask(final Integer i) {
27-
// if (true) throw new RuntimeException();
26+
// if (true) throw new RuntimeException();
2827
return Task.callable("number", () -> i);
2928
}
3029

3130
@Override
32-
protected void doRunExample(final Engine engine) throws Exception
33-
{
34-
Task<?> task = ParSeqCollection.fromValues(numbers)
35-
.mapTask(SumExample::toTask)
36-
.reduce((a, b) -> a + b)
37-
.map(sum -> "result: " + sum)
38-
.recover(e -> "error")
39-
.andThen(System.out::println);
31+
protected void doRunExample(final Engine engine) throws Exception {
32+
Task<?> task = ParSeqCollection.fromValues(numbers).mapTask(SumExample::toTask).reduce((a, b) -> a + b)
33+
.map(sum -> "result: " + sum).recover(e -> "error").andThen(System.out::println);
4034

4135
engine.run(task);
4236

example/com/linkedin/parseq/example/collections/SyncCollectionExample.java

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,20 @@
1010
import com.linkedin.parseq.example.common.AbstractExample;
1111
import com.linkedin.parseq.example.common.ExampleUtil;
1212

13+
1314
/**
1415
* @author Jaroslaw Odzga (jodzga@linkedin.com)
1516
*/
16-
public class SyncCollectionExample extends AbstractExample
17-
{
18-
public static void main(String[] args) throws Exception
19-
{
17+
public class SyncCollectionExample extends AbstractExample {
18+
public static void main(String[] args) throws Exception {
2019
new SyncCollectionExample().runExample();
2120
}
2221

2322
@Override
24-
protected void doRunExample(final Engine engine) throws Exception
25-
{
23+
protected void doRunExample(final Engine engine) throws Exception {
2624
List<String> urls = Arrays.asList("http://www.linkedin.com", "http://www.google.com", "http://www.twitter.com");
2725

28-
29-
Task<String> task = ParSeqCollection.fromValues(urls)
30-
.reduce((a, b) -> a + ", " + b)
31-
.andThen(System.out::println);
26+
Task<String> task = ParSeqCollection.fromValues(urls).reduce((a, b) -> a + ", " + b).andThen(System.out::println);
3227

3328
engine.run(task);
3429

0 commit comments

Comments
 (0)