Skip to content

Commit

Permalink
refactor package names
Browse files Browse the repository at this point in the history
  • Loading branch information
mariofusco committed Jul 15, 2014
1 parent a9c7a38 commit b734604
Show file tree
Hide file tree
Showing 75 changed files with 148 additions and 151 deletions.
4 changes: 2 additions & 2 deletions src/main/java/lambdasinaction/appc/StreamForkerExample.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package lambdasinaction.appc;

import lambdasinaction.chap5.*;
import lambdasinaction.chap6.*;

import static java.util.stream.Collectors.*;
import static lambdasinaction.chap5.Dish.menu;
import static lambdasinaction.chap6.Dish.menu;

import java.util.*;
import java.util.stream.*;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package lambdasinaction.chap9;
package lambdasinaction.chap10;

import java.util.*;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package lambdasinaction.chap9;
package lambdasinaction.chap10;

public class Insurance {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package lambdasinaction.chap9;
package lambdasinaction.chap10;

import java.util.*;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package lambdasinaction.chap9;
package lambdasinaction.chap10;

import java.util.*;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package lambdasinaction.chap9;
package lambdasinaction.chap10;

import java.util.*;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package lambdasinaction.chap9;
package lambdasinaction.chap10;

import org.junit.*;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package lambdasinaction.chap10;
package lambdasinaction.chap11;

import static lambdasinaction.chap10.Util.delay;
import static lambdasinaction.chap10.Util.format;
import static lambdasinaction.chap11.Util.delay;
import static lambdasinaction.chap11.Util.format;

import java.util.Random;
import java.util.concurrent.CompletableFuture;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package lambdasinaction.chap10;
package lambdasinaction.chap11;

import java.util.concurrent.Future;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package lambdasinaction.chap10;
package lambdasinaction.chap11;

import java.util.Arrays;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package lambdasinaction.chap10;
package lambdasinaction.chap11;

import java.util.List;
import java.util.function.Supplier;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package lambdasinaction.chap10;
package lambdasinaction.chap11;

import static lambdasinaction.chap10.Util.delay;
import static lambdasinaction.chap10.Util.format;
import static lambdasinaction.chap11.Util.delay;
import static lambdasinaction.chap11.Util.format;

public class Discount {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package lambdasinaction.chap10;
package lambdasinaction.chap11;

import static lambdasinaction.chap10.Util.delay;
import static lambdasinaction.chap11.Util.delay;

public class ExchangeService {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package lambdasinaction.chap10;
package lambdasinaction.chap11;

public class Quote {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package lambdasinaction.chap10;
package lambdasinaction.chap11;

import static lambdasinaction.chap10.Util.delay;
import static lambdasinaction.chap10.Util.format;
import static lambdasinaction.chap11.Util.delay;
import static lambdasinaction.chap11.Util.format;

import java.util.Random;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package lambdasinaction.chap10;
package lambdasinaction.chap11;

import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package lambdasinaction.chap10.v1;
package lambdasinaction.chap11.v1;

import java.util.ArrayList;
import java.util.Arrays;
Expand All @@ -14,8 +14,8 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;

import lambdasinaction.chap10.ExchangeService;
import lambdasinaction.chap10.ExchangeService.Money;
import lambdasinaction.chap11.ExchangeService;
import lambdasinaction.chap11.ExchangeService.Money;

public class BestPriceFinder {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package lambdasinaction.chap10.v1;
package lambdasinaction.chap11.v1;

import java.util.List;
import java.util.function.Supplier;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package lambdasinaction.chap10.v1;
package lambdasinaction.chap11.v1;

import static lambdasinaction.chap10.Util.delay;
import static lambdasinaction.chap11.Util.delay;

import java.util.Random;
import java.util.concurrent.CompletableFuture;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package lambdasinaction.chap10.v1;
package lambdasinaction.chap11.v1;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package lambdasinaction.chap11;
package lambdasinaction.chap12;

import static java.time.temporal.TemporalAdjusters.lastDayOfMonth;
import static java.time.temporal.TemporalAdjusters.nextOrSame;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package lambdasinaction.chap12;
package lambdasinaction.chap13;

import java.util.stream.LongStream;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package lambdasinaction.chap12;
package lambdasinaction.chap13;

import java.util.ArrayList;
import java.util.Arrays;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package lambdasinaction.chap13;
package lambdasinaction.chap14;

import java.util.function.Function;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package lambdasinaction.chap13;
package lambdasinaction.chap14;

import java.util.function.DoubleUnaryOperator;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package lambdasinaction.chap13;
package lambdasinaction.chap14;

import java.util.function.Supplier;
import java.util.function.Predicate;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package lambdasinaction.chap13;
package lambdasinaction.chap14;

import java.util.function.Function;
import java.util.function.Supplier;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package lambdasinaction.chap13;
package lambdasinaction.chap14;

import java.util.function.Consumer;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package lambdasinaction.chap13;
package lambdasinaction.chap14;

public class PersistentTree {

Expand Down
29 changes: 0 additions & 29 deletions src/main/java/lambdasinaction/chap4/Reducing.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package lambdasinaction.chap4;
package lambdasinaction.chap5;

import java.util.*;
import java.util.function.IntSupplier;
import java.util.stream.*;
import static java.util.stream.Collectors.toList;
import java.nio.charset.Charset;
import java.nio.file.*;

Expand Down Expand Up @@ -67,7 +66,7 @@ public int getAsInt(){
};
IntStream.generate(fib).limit(10).forEach(System.out::println);

long uniqueWords = Files.lines(Paths.get("lambdasinaction/chap4/data.txt"), Charset.defaultCharset())
long uniqueWords = Files.lines(Paths.get("lambdasinaction/chap5/data.txt"), Charset.defaultCharset())
.flatMap(line -> Arrays.stream(line.split(" ")))
.distinct()
.count();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
package lambdasinaction.chap4;
package lambdasinaction.chap5;
import lambdasinaction.chap4.*;

import java.util.stream.*;
import java.util.*;
import static java.util.stream.Collectors.toList;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
package lambdasinaction.chap4;
package lambdasinaction.chap5;
import lambdasinaction.chap4.*;

import java.util.stream.*;
import java.util.*;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package lambdasinaction.chap4;
package lambdasinaction.chap5;

import java.util.Arrays;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
package lambdasinaction.chap4;
package lambdasinaction.chap5;

import lambdasinaction.chap4.*;

import java.util.*;
import static java.util.stream.Collectors.toList;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
package lambdasinaction.chap4;
package lambdasinaction.chap5;
import lambdasinaction.chap4.*;

import java.util.stream.*;
import java.util.*;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package lambdasinaction.chap4;
package lambdasinaction.chap5;

import lambdasinaction.chap5.*;

import java.util.*;
import java.util.stream.*;

import static java.util.Comparator.comparing;
import static java.util.stream.Collectors.toList;

Expand Down
43 changes: 20 additions & 23 deletions src/main/java/lambdasinaction/chap5/Reducing.java
Original file line number Diff line number Diff line change
@@ -1,34 +1,31 @@
package lambdasinaction.chap5;
import lambdasinaction.chap4.*;

import java.util.*;
import java.util.function.*;
import java.util.stream.*;
import java.util.*;

import static java.util.stream.Collectors.*;
import static lambdasinaction.chap5.Dish.menu;
import static lambdasinaction.chap4.Dish.menu;

public class Reducing {
public class Reducing{

public static void main(String ... args) {
System.out.println("Total calories in menu: " + calculateTotalCalories());
System.out.println("Total calories in menu: " + calculateTotalCaloriesWithMethodReference());
System.out.println("Total calories in menu: " + calculateTotalCaloriesWithoutCollectors());
System.out.println("Total calories in menu: " + calculateTotalCaloriesUsingSum());
}
public static void main(String...args){

private static int calculateTotalCalories() {
return menu.stream().collect(reducing(0, Dish::getCalories, (Integer i, Integer j) -> i + j));
}
List<Integer> numbers = Arrays.asList(3,4,5,1,2);
int sum = numbers.stream().reduce(0, (a, b) -> a + b);
System.out.println(sum);

private static int calculateTotalCaloriesWithMethodReference() {
return menu.stream().collect(reducing(0, Dish::getCalories, Integer::sum));
}
int sum2 = numbers.stream().reduce(0, Integer::sum);
System.out.println(sum2);

private static int calculateTotalCaloriesWithoutCollectors() {
return menu.stream().map(Dish::getCalories).reduce(Integer::sum).get();
}
int max = numbers.stream().reduce(0, (a, b) -> Integer.max(a, b));
System.out.println(max);

Optional<Integer> min = numbers.stream().reduce(Integer::min);
min.ifPresent(System.out::println);

private static int calculateTotalCaloriesUsingSum() {
return menu.stream().mapToInt(Dish::getCalories).sum();
int calories = menu.stream()
.map(Dish::getCalories)
.reduce(0, Integer::sum);
System.out.println("Number of calories:" + calories);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package lambdasinaction.chap4;
package lambdasinaction.chap5;
public class Trader{

private String name;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
package lambdasinaction.chap4;
package lambdasinaction.chap5;

public class Transaction{

private Trader trader;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package lambdasinaction.chap5;
package lambdasinaction.chap6;

import java.util.function.*;

import static lambdasinaction.chap5.PartitionPrimeNumbers.*;

public class CollectorHarness {

public static void main(String[] args) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package lambdasinaction.chap5;
package lambdasinaction.chap6;

import java.util.*;

Expand Down
Loading

0 comments on commit b734604

Please sign in to comment.