Giter VIP home page Giter VIP logo

java8inaction's People

Contributors

java8 avatar jcabmora avatar jeffmorin avatar mariofusco avatar phillips1021 avatar raouldoc avatar romankagan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

java8inaction's Issues

lambdasinaction code example Eorror In Chap3

I downloaded the lambdasinaction code example, but there are some errors.
For example:
The method flatMapping(( dish) -> {}, toSet()) is undefined for the type Grouping in chap3 package, The code: private static Map<Dish.Type, Set<String>> groupDishTagsByType() { return menu.stream().collect(groupingBy(Dish::getType, flatMapping(dish -> dishTags.get( dish.getName() ).stream(), toSet()))); }

And The method filtering(( dish) -> {}, toList()) is undefined for the type Grouping in chap3 package, The code private static Map<Dish.Type, List<Dish>> groupCaloricDishesByType() { return menu.stream().collect(groupingBy(Dish::getType, filtering(dish -> dish.getCalories() > 500, toList()))); }

When I practice, encountered a lot of errors . The method toList() 、groupingBy、comparing()....is undefined for the type TestStream.
By the way, i used jdk 1.8.0.171,Is it because the JDK version is too low ?

Chapter 10 examples,I got error!

Can you run?I can not successfully run the OptionalMain.java.What went wrong,Here
public String getCarInsuranceName(Optional<Person> person) { return person.flatMap(Person::getCar) .flatMap(Car::getInsurance) .map(Insurance::getName) .orElse("Unknown"); }

I got NullPointException.The Exception:
image

有些方法找不到 Some method is undefined

class: lambdasinaction.chap10.OperationsWithOptional
line 15 and line 18
The method or(() -> {}) is undefined for the type Optional


class: lambdasinaction.chap10.OptionalMain
line 21
The method flatMap(Function<? super Optional,? extends Stream<? extends R>>) in the type Stream<Optional> is not applicable for the arguments (Optional::stream)


class: lambdasinaction.chap6.Grouping
line 36
The method flatMapping(( dish) -> {}, toSet()) is undefined for the type Grouping

line 41
The method filtering(( dish) -> {}, toList()) is undefined for the type Grouping


class: lambdasinaction.chap6.PartitionPrimeNumbers
line 36
The method takeWhile(( i) -> {}) is undefined for the type Stream

Stream() API support for Array

String[] stringArray = {"A,B","B,A","C,D","C,B","A,V"};
stringArray.stream() ------>> Cannot invoke stream() on the array type String[]

is it not good to have streaming on Array as well? :)

the class PartitionPrimeNumbers has an error at line 36 and don't compile

public static boolean isPrime(List<Integer> primes, Integer candidate) {
    double candidateRoot = Math.sqrt((double) candidate);
    //return takeWhile(primes, i -> i <= candidateRoot).stream().noneMatch(i -> candidate % i == 0);
    return primes.stream().**takeWhile**(i -> i <= candidateRoot).noneMatch(i -> candidate % i == 0);
}

-> the function takeWhile is invalid or doesn't exists

Cannot infer type argument(s) for <R> map(Function<? super T,? extends R>)

BestPriceFinder.java

public Stream<CompletableFuture> findPricesStream(String product) {
return shops.stream()
.map(shop -> CompletableFuture.supplyAsync(() -> shop.getPrice(product), executor))
.map(future -> future.thenApply(Quote::parse))
.map(future -> future.thenCompose(quote -> CompletableFuture.supplyAsync(() -> Discount.applyDiscount(quote), executor)));
}

Grouping class has two errors with undefined functions at line 36 and 41

private static Map<Dish.Type, Set> groupDishTagsByType() {
return menu.stream().collect(groupingBy(Dish::getType, flatMapping(dish -> dishTags.get( dish.getName() ).stream(), toSet())));
}
-> flatMapping shown as invalid and don't compile the class

private static Map<Dish.Type, List<Dish>> groupCaloricDishesByType() {

// return menu.stream().filter(dish -> dish.getCalories() > 500).collect(groupingBy(Dish::getType));
return menu.stream().collect(groupingBy(Dish::getType, filtering(dish -> dish.getCalories() > 500, toList())));
}
-> filtering shown as invalid and don't compile the class

BUILD FAILURE

I try to compile sources on Mac with Java 1.8.0_91

I get:
chojnasm-ml:Java8InAction chojnasm$ mvn compile
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for manning:lambdasinaction:jar:1.0
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-shade-plugin is missing. @ line 44, column 15
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building lambdasinaction 1.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ lambdasinaction ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 2 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ lambdasinaction ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 100 source files to /Users/chojnasm/Downloads/Java8InAction/target/classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.558 s
[INFO] Finished at: 2017-02-27T14:27:45+00:00
[INFO] Final Memory: 9M/309M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project lambdasinaction: Fatal error compiling: invalid target release: 1.9 -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.