Pular para o conteúdo principal

Postagens

Mostrando postagens com o rótulo java8

4 Real World Lambdas with Collections examples

I love functional programming and I'm exciting not only about Lambda , but also about the stream API  and the new functional interfaces that comes with Java 8, which was released recently . In the next lines I'll show some codes I took from some Java projects in github and rewrote it using Java 8. Notice obviously I had to mock some classes just to focus on the code rewrite. If you find a better way to do this, please let me know! Code on Github 1) Concatenating a List into a String Original public static String matrixparamtest(PathSegment id){ StringBuffer sb = new StringBuffer(); sb.append("matrix="); sb.append("/" + id.getPath()); Map matrix = id.getMatrixParameters(); Set keys = matrix.keySet(); for (Object key : keys) { sb.append(";" + key.toString() + "=" + matrix.get(key.toString())); } return sb...

A minimal Java 8 project using Maven

To use Java 8 with Maven is easy. Maven already supports it and it's good for JavaFX developers that a Java 8 is a JavaFX 8 application already! To make easy the creation of new projects using JavaFX 8, I created an archetype for JavaFX applications. It will be useful for me, so it might be useful for someone else as well. Using Maven with JavaFX 8 Having Maven 3.x and a Java 8 newest build, you are able to create JavaFX 8 applications using Maven! I created a "Hello World" application to serve as a starting point for new applications. The pom.xml is on github and the directories structure is as follow: Building and Running from Maven Make sure you export JAVA_HOME to the root path of your Java 8 installation. In my case, before running Maven I used the followin command (in Ubuntu 12.04): $  export JAVA_HOME=/opt/java/jdk1.8.0/  After this you should be able to build your project: $ mvn clean project Notice that in the root direc...