X Tutup
Skip to content

Commit 2494eac

Browse files
committed
mod bug
1 parent 4786c46 commit 2494eac

File tree

4 files changed

+15
-14
lines changed

4 files changed

+15
-14
lines changed

src/main/java/lambdasinaction/chap10/OperationsWithOptional.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@ public static void main(String... args) {
1212
System.out.println(max(empty(), of(5)));
1313

1414
Optional<Integer> opt1 = of(5);
15-
Optional<Integer> opt2 = opt1.or(() -> of(4));
15+
//Optional<Integer> opt2 = opt1.or(() -> of(4));
1616

17-
System.out.println(
18-
of(5).or(() -> of(4))
19-
);
17+
//System.out.println(of(5).or(() -> of(4)));
2018
}
2119

2220
public static final Optional<Integer> max(Optional<Integer> i, Optional<Integer> j) {

src/main/java/lambdasinaction/chap10/OptionalMain.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@ public String getCarInsuranceName(Optional<Person> person) {
1414
}
1515

1616
public Set<String> getCarInsuranceNames(List<Person> persons) {
17-
return persons.stream()
18-
.map(Person::getCar)
19-
.map(optCar -> optCar.flatMap(Car::getInsurance))
20-
.map(optInsurance -> optInsurance.map(Insurance::getName))
21-
.flatMap(Optional::stream)
22-
.collect(toSet());
17+
// return persons.stream()
18+
// .map(Person::getCar)
19+
// .map(optCar -> optCar.flatMap(Car::getInsurance))
20+
// .map(optInsurance -> optInsurance.map(Insurance::getName))
21+
// .flatMap(Optional::stream)
22+
// .collect(toSet());
23+
return null;
2324
}
2425
}

src/main/java/lambdasinaction/chap6/Grouping.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,13 @@ private static Map<Dish.Type, List<String>> groupDishNamesByType() {
3333
}
3434

3535
private static Map<Dish.Type, Set<String>> groupDishTagsByType() {
36-
return menu.stream().collect(groupingBy(Dish::getType, flatMapping(dish -> dishTags.get( dish.getName() ).stream(), toSet())));
36+
return null;
37+
//return menu.stream().collect(groupingBy(Dish::getType, flatMapping(dish -> dishTags.get( dish.getName() ).stream(), toSet())));
3738
}
3839

3940
private static Map<Dish.Type, List<Dish>> groupCaloricDishesByType() {
40-
// return menu.stream().filter(dish -> dish.getCalories() > 500).collect(groupingBy(Dish::getType));
41-
return menu.stream().collect(groupingBy(Dish::getType, filtering(dish -> dish.getCalories() > 500, toList())));
41+
return menu.stream().filter(dish -> dish.getCalories() > 500).collect(groupingBy(Dish::getType));
42+
//return menu.stream().collect(groupingBy(Dish::getType, filtering(dish -> dish.getCalories() > 500, toList())));
4243
}
4344

4445
private static Map<CaloricLevel, List<Dish>> groupDishesByCaloricLevel() {

src/main/java/lambdasinaction/chap6/PartitionPrimeNumbers.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ public static Map<Boolean, List<Integer>> partitionPrimesWithCustomCollector(int
3333
public static boolean isPrime(List<Integer> primes, Integer candidate) {
3434
double candidateRoot = Math.sqrt((double) candidate);
3535
//return takeWhile(primes, i -> i <= candidateRoot).stream().noneMatch(i -> candidate % i == 0);
36-
return primes.stream().takeWhile(i -> i <= candidateRoot).noneMatch(i -> candidate % i == 0);
36+
//return primes.stream().takeWhile(i -> i <= candidateRoot).noneMatch(i -> candidate % i == 0);
37+
return true;
3738
}
3839
/*
3940
public static <A> List<A> takeWhile(List<A> list, Predicate<A> p) {

0 commit comments

Comments
 (0)
X Tutup