SlideShare a Scribd company logo
1 of 160
Download to read offline
@Delabassee @JosePaumard
Java EE devs
Java SE 8 for
@Delabassee @JosePaumard#SE84EE
Agenda
Java SE 8 has been published ~1 year ago
Java EE 7 application servers are supporting it now
(Weblogic)
@Delabassee @JosePaumard#SE84EE
Questions?
#SE84EE
@JosePaumard
@JosePaumard
Date
@Delabassee @JosePaumard#SE84EE
Date: Instant
An Instant is a point on the time line
Instant start = Instant.now() ;
Instant end = Instant.now() ;
@Delabassee @JosePaumard#SE84EE
Date: Duration
A « duration » is the amount of time between instants
Instant start = Instant.now() ;
Instant end = Instant.now() ;
Duration elapsed = Duration.between(start, end) ;
long millis = elapsed.toMillis() ;
@Delabassee @JosePaumard#SE84EE
Date: Duration
There is an arithmetic on durations
Instant start = Instant.now() ;
Instant end = Instant.now() ;
Duration elapsed = Duration.between(start, end) ;
long millis = elapsed.toMillis() ;
elapsed.plus(2L, ChronoUnit.SECONDS) ;
@Delabassee @JosePaumard#SE84EE
Date: Duration
The precision of the time line is 10-9 s (nanosecond)
@Delabassee @JosePaumard#SE84EE
Date: LocalDate
A LocalDate is an « every day » date
LocalDate now = LocalDate.now() ;
LocalDate shakespeareDoB =
LocaleDate.of(1564, Month.APRIL, 23) ;
@Delabassee @JosePaumard#SE84EE
Date: Period
A « period » is the amount of time between local dates
LocalDate now = LocalDate.now() ;
LocalDate shakespeareDoB =
LocaleDate.of(1564, Month.APRIL, 23) ;
Period p = shakespeareDoB.until(now) ;
System.out.println("# years = " + p.getYears()) ;
@Delabassee @JosePaumard#SE84EE
Date: Period
A « period » is the amount of time between local dates
LocalDate now = LocalDate.now() ;
LocalDate shakespeareDoB =
LocaleDate.of(1564, Month.APRIL, 23) ;
Period p = shakespeareDoB.until(now) ;
System.out.println("# years = " + p.getYears()) ;
long days = shakespeareDoB.until(now, ChronoUnit.DAYS) ;
System.out.println("# days = " + days) ;
@Delabassee @JosePaumard#SE84EE
Date: TemporalAdjuster
Arithmetic with local dates
LocalDate now = LocalDate.now() ;
LocalDate nextSunday =
now.with(TemporalAdjusters.next(DayOfWeek.SUNDAY)) ;
@Delabassee @JosePaumard#SE84EE
Date: TemporalAdjuster
Arithmetic with local dates
A toolbox of 14 static methods
firstDayOfMonth(), lastDayOfYear()
firstDayOfNextMonth()
LocalDate now = LocalDate.now() ;
LocalDate nextSunday =
now.with(TemporalAdjusters.next(DayOfWeek.SUNDAY)) ;
@Delabassee @JosePaumard#SE84EE
Date: TemporalAdjuster
Arithmetic with local dates
A toolbox of 14 static methods
firstInMonth(DayOfWeek.MONDAY)
next(DayOfWeek.FRIDAY)
LocalDate now = LocalDate.now() ;
LocalDate nextSunday =
now.with(TemporalAdjusters.next(DayOfWeek.SUNDAY)) ;
@Delabassee @JosePaumard#SE84EE
Date: LocalTime
A LocalTime is an everyday time: ex. 10:20
LocalTime now = LocalTime.now() ;
LocalTime time = LocalTime.of(10, 20) ; // 10:20
@Delabassee @JosePaumard#SE84EE
Date: LocalTime
A LocalTime is an everyday time: ex. 10:20
LocalTime now = LocalTime.now() ;
LocalTime time = LocalTime.of(10, 20) ; // 10:20
LocalTime lunchTime = LocalTime.of(12, 30) ;
LocalTime coffeeTime = lunchTime.plusHours(2) ; // 14:20
@Delabassee @JosePaumard#SE84EE
Date: ZonedTime
Useful for localized times
Set<String> allZonesIds = ZoneId.getAvailableZoneIds() ;
String ukTZ = ZoneId.of("Europe/London") ;
@Delabassee @JosePaumard#SE84EE
Date: ZonedTime
Useful for localized times
System.out.println(
ZonedDateTime.of(
1564, Month.APRIL.getValue(), 23, // year / month / day
10, 0, 0, 0, // h / mn / s / nanos
ZoneId.of("Europe/London"))
); // prints 1564-04-23T10:00-00:01:15[Europe/London]
@Delabassee @JosePaumard#SE84EE
Date: ZonedTime
Arithmetic on localized time
ZonedDateTime currentMeeting =
ZonedDateTime.of(
LocalDate.of(2014, Month.APRIL, 18), // LocalDate
LocalTime.of(9, 30), // LocalTime
ZoneId.of("Europe/London")
);
ZonedDateTime nextMeeting =
currentMeeting.plus(Period.ofMonth(1));
@Delabassee @JosePaumard#SE84EE
Date: ZonedTime
Arithmetic on localized time
ZonedDateTime currentMeeting =
ZonedDateTime.of(
LocalDate.of(2014, Month.APRIL, 18), // LocalDate
LocalTime.of(9, 30), // LocalTime
ZoneId.of("Europe/London")
);
ZonedDateTime nextMeeting =
currentMeeting.plus(Period.ofMonth(1)) ;
ZonedDateTime nextMeetingUS =
nextMeeting.withZoneSameInstant(ZoneId.of("US/Central")) ;
@Delabassee @JosePaumard#SE84EE
Date: Formatter
Factory class: DateTimeFormatter
ZonedDateTime nextMeetingUS =
nextMeeting.withZoneSameInstant(ZoneId.of("US/Central"));
System.out.println(
DateTimeFormatter.ISO_DATE_TIME.format(nextMeetingUS)
);
// prints 2014-04-12T03:30:00-05:00[US/Central]
System.out.println(
DateTimeFormatter.RFC_1123_DATE_TIME.format(nextMeetingUS)
);
// prints Sat, 12 Apr 2014 03:30:00 -0500
@Delabassee @JosePaumard#SE84EE
Date: bridges with java.util.Date
API to go from legacy Date to Date & Time
Date date = Date.from(instant); // API -> legacy
Instant instant = date.toInstant(); // legacy -> new API
@Delabassee @JosePaumard#SE84EE
Date: bridges with java.util.Date
API to go from legacy Date to Date & Time
TimeStamp time = TimeStamp.from(instant); // API -> legacy
Instant instant = time.toInstant(); // legacy -> new API
Date date = Date.from(instant); // API -> legacy
Instant instant = date.toInstant(); // legacy -> new API
@Delabassee @JosePaumard#SE84EE
Date: bridges with java.util.Date
API to go from legacy Date to Date & Time
Date date = Date.from(localDate); // API -> legacy
LocalDate localDate = date.toLocalDate(); // legacy -> new API
TimeStamp time = TimeStamp.from(instant); // API -> legacy
Instant instant = time.toInstant(); // legacy -> new API
Date date = Date.from(instant); // API -> legacy
Instant instant = date.toInstant(); // legacy -> new API
@Delabassee @JosePaumard#SE84EE
Date: bridges with java.util.Date
API to go from legacy Date to Date & Time
Time time = Time.from(localTime); // API -> legacy
LocalTime localTime = time.toLocalTime(); // legacy -> new API
Date date = Date.from(localDate); // API -> legacy
LocalDate localDate = date.toLocalDate(); // legacy -> new API
TimeStamp time = TimeStamp.from(instant); // API -> legacy
Instant instant = time.toInstant(); // legacy -> new API
Date date = Date.from(instant); // API -> legacy
Instant instant = date.toInstant(); // legacy -> new API
@Delabassee @JosePaumard#SE84EE
Usable in JPA
JPA does not support this Date & Time API (yet)
But with converters, we can still use it
@Entity
public abstract class AbstractPersistent {
@Convert(converter=DateConverter.class)
@Temporal(TemporalType.TIME)
private Instant instance;
}
@Delabassee @JosePaumard#SE84EE
Usable in JPA
The converter is a classical object
public class DateConverter
implements AttributeConverter<Instant, Date> {
public Date convertToDatabaseColumn(Instant instant) {
return Date.from(instant);
}
public Instant convertToEntityAttribute(Date date) {
return date.toInstant();
}
}
@Delabassee @JosePaumard#SE84EE
Usable in JPA
The converter is a classical object
public class DateFormatConverter
implements AttributeConverter<ZonedDateTime, String> {
public String convertToDatabaseColumn(ZonedDateTime time) {
return DateTimeFormatter.ISO_DATE_TIME.format(time);
}
public ZonedDateTime convertToEntityAttribute(String formated) {
return DateTimeFormatter.ISO_DATE_TIME
.parse(formated, ZonedDateTime::from);
}
}
Annotations
@Delabassee @JosePaumard#SE84EE
Annotations in Java 7
Wrapping annotations
An annotation cannot be applied more than once
@TestCases({
@TestCase(param=1, expected=false),
@TestCase(param=2, expected=true)
})
public boolean even(int param) {
return param % 2 == 0;
}
@Delabassee @JosePaumard#SE84EE
Annotations in Java 8
Java 8 makes it possible!
@TestCase(param=1, expected=false),
@TestCase(param=2, expected=true)
public boolean even(int param) {
return param % 2 == 0;
}
@Delabassee @JosePaumard#SE84EE
How does it work?
It’s a trick!
@Delabassee @JosePaumard#SE84EE
How does it work?
First: create the annotations as usual
@interface TestCase {
int param();
boolean expected();
}
@interface TestCases {
TestCase[] value();
}
@Delabassee @JosePaumard#SE84EE
How does it work?
Second: make the annotation repeatable
@Repeatable(TestCases.class)
@interface TestCase {
int param();
boolean expected();
}
@interface TestCases {
TestCase[] value();
}
@Delabassee @JosePaumard#SE84EE
Type annotations
Annotations can be now put on types
Example 1: tell that a variable should not be null
private @NonNull List<Person> persons = ... ;
@Delabassee @JosePaumard#SE84EE
Type annotations
Annotations can be now put on types
Example 1: tell that a variable should not be null
Example 2: the content should not be null neither
private @NonNull List<Person> persons = ... ;
private @NonNull List<@NonNull Person> persons = ... ;
String
@Delabassee @JosePaumard#SE84EE
String: concatenation
The newbie writes:
String s1 = "hello" ;
String s2 = " world!" ;
String s3 = s1 + " " + s2 ;
@Delabassee @JosePaumard#SE84EE
String: concatenation
The Java 8 well-trained dev writes:
// The JDK 8 way
StringJoiner sj = new StringJoiner(", ") ;
sj.add("one").add("two").add("three") ;
String s = sj.toString() ;
System.out.println(s) ;
@Delabassee @JosePaumard#SE84EE
String: concatenation
The Java 8 well-trained dev writes:
And it prints:
// The JDK 8 way
StringJoiner sj = new StringJoiner(", ") ;
sj.add("one").add("two").add("three") ;
String s = sj.toString() ;
System.out.println(s) ;
> one, two, three
@Delabassee @JosePaumard#SE84EE
String: concatenation
The Java 8 well-trained dev writes:
And it prints:
// The JDK 8 way
StringJoiner sj = new StringJoiner(", ") ;
sj.add("one") ;
String s = sj.toString() ;
System.out.println(s) ;
> one
@Delabassee @JosePaumard#SE84EE
String: concatenation
The Java 8 well-trained dev writes:
And it prints:
// The JDK 8 way
StringJoiner sj = new StringJoiner(", ", "{", "}") ;
sj.add("one").add("two").add("three") ;
String s = sj.toString() ;
System.out.println(s) ;
> {one, two, three}
@Delabassee @JosePaumard#SE84EE
String: concatenation
The Java 8 well-trained dev writes:
And it prints:
// The JDK 8 way
StringJoiner sj = new StringJoiner(", ", "{", "}") ;
sj.add("one") ;
String s = sj.toString() ;
System.out.println(s) ;
> {one}
@Delabassee @JosePaumard#SE84EE
String: concatenation
The Java 8 well-trained dev writes:
And it prints:
// The JDK 8 way
StringJoiner sj = new StringJoiner(", ", "{", "}") ;
// we dont put anything in it
String s = sj.toString() ;
System.out.println(s) ;
> {}
@Delabassee @JosePaumard#SE84EE
String: concatenation
And it’s nearly accessible from the String class itself:
And it prints:
// From the String class, with a vararg
String s = String.join(", ", "one", "two", "three");
System.out.println(s);
> one, two, three
@Delabassee @JosePaumard#SE84EE
String: concatenation
And it’s nearly accessible from the String class itself:
And it prints:
// From the String class, with an Iterable
String [] tab = {"one", "two", "three"} ;
String s = String.join(", ", tab) ;
System.out.println(s) ;
> one, two, three
@Delabassee @JosePaumard#SE84EE
String: concatenation
And it’s nearly accessible from the String class itself:
And it prints:
// From the String class, with an Iterable
String [] tab = {"one", "two", "three"} ;
String s = String.join(", ", tab) ;
System.out.println(s) ;
> one, two, three
Comparator
@Delabassee @JosePaumard#SE84EE
The good ol’ way!
Comparator!
// comparison using the last name
Comparator<Person> compareLastName =
new Comparator<Person>() {
@Override
public int compare(Person p1, Person p2) {
return p1.getLastName().compareTo(p2.getLastName());
}
};
@Delabassee @JosePaumard#SE84EE
Comparator!
// comparison using the last name then the first name
Comparator<Person> compareLastNameThenFirstName =
new Comparator<Person>() {
@Override
public int compare(Person p1, Person p2) {
int lastNameComparison =
p1.getLastName().compareTo(p2.getLastName());
return lastNameComparison == 0 ?
p2.getFirstName().compareTo(p2.getFirstName());
lastNameComparison;
}
};
@Delabassee @JosePaumard#SE84EE
Comparator!
The JDK 8 way!
Comparator.comparingBy(Person::getLastName); // static method
@Delabassee @JosePaumard#SE84EE
Comparator!
The JDK 8 way!
Comparator.comparingBy(Person::getLastName) // static method
.thenComparing(Person::getFirstName); // default method
@Delabassee @JosePaumard#SE84EE
Comparator!
The JDK 8 way!
Comparator.comparingBy(Person::getLastName) // static method
.thenComparing(Person::getFirstName) // default method
.thenComparing(Person::getAge);
@Delabassee @JosePaumard#SE84EE
Comparator!
Dont like the natural order?
Comparator<Person> comp = Comparator.naturalOrder();
Comparator<Person> reversedComp = Comparator.reversedOrder();
@Delabassee @JosePaumard#SE84EE
Comparator!
Dont like the natural order?
Comparator<Person> comp = Comparator.comparingBy(Person::getLastName);
Comparator<Person> reversedComp = comp.reversed();
@Delabassee @JosePaumard#SE84EE
Comparator!
And what about null values?
Comparator<Person> comp =
Comparator.naturalOrder();
@Delabassee @JosePaumard#SE84EE
Comparator!
And what about null values?
Comparator<Person> comp =
Comparator.nullsFirst(Comparator.naturalOrder());
@Delabassee @JosePaumard#SE84EE
Comparator!
And what about null values?
Comparator<Person> comp =
Comparator.nullsFirst(Comparator.naturalOrder());
Comparator<Person> comp =
Comparator.nullsLast(Comparator.naturalOrder());
List
@Delabassee @JosePaumard#SE84EE
Iterable: forEach
ForEach: consumes the elements
Doesn’t work on arrays
// method forEach defined on Iterable
List<String> strings =
Arrays.asList("one", "two", "three") ;
strings.forEach(System.out::println) ;
> one, two, three
@Delabassee @JosePaumard#SE84EE
Collection: removeIf
Removes an object, takes a Predicate
Collection<String> strings =
Arrays.asList("one", "two", "three", "four");
// works « in place », no Collections.unmodifiable...
Collection<String> list = new ArrayList<>(strings);
// returns true if the list has been modified
boolean b = list.removeIf(s -> s.length() > 4);
> one, two, four
@Delabassee @JosePaumard#SE84EE
List: replaceAll
Replaces an object with its transform
List<String> strings =
Arrays.asList("one", "two", "three", "four");
// works « in place », no Collections.unmodifiable...
List<String> list = new ArrayList<>(strings);
// returns nothing
list.replaceAll(String::toUpperCase);
> ONE, TWO, THREE, FOUR
@Delabassee @JosePaumard#SE84EE
List: sort
Sorts a List in place, takes a Comparator
List<String> strings =
Arrays.asList("one", "two", "three", "four");
// works « in place », no Collections.unmodifiable...
List<String> list = new ArrayList<>(strings);
// returns nothing
list.sort(Comparator.naturalOrder()) ;
> four, one, three, two
@Delabassee @JosePaumard#SE84EE
What we might have in 9 (JEP 269)
New patterns to build collections
Set<String> strings = Set.of("one", "two", "three", "four");
List<String> strings = List.of("one", "two", "three", "four");
Map
@Delabassee @JosePaumard#SE84EE
Map: forEach
Takes a BiConsumer
// the existing map
Map<String, Person> map = ... ;
map.forEach(
(key, value) -> System.out.println(key + " -> " + value)
) ;
@Delabassee @JosePaumard#SE84EE
Map: get
What happens if key is not in the map?
// the existing map
Map<String, Person> map = ... ;
Person p = map.get(key);
@Delabassee @JosePaumard#SE84EE
Map: get
// the existing map
Map<String, Person> map = ... ;
Person p = map.getOrDefault(key, Person.DEFAULT_PERSON);
@Delabassee @JosePaumard#SE84EE
Map: put
// the existing map
Map<String, Person> map = ... ;
map.put(key, person);
@Delabassee @JosePaumard#SE84EE
Map: putIfAbsent
// the existing map
Map<String, Person> map = ... ;
map.put(key, person);
map.putIfAbsent(key, person);
@Delabassee @JosePaumard#SE84EE
Map: replace
Replaces a value from its key
// the existing map
Map<String, Person> map = ... ;
// key, newValue
map.replace("six", john) ;
// key, oldValue, newValue
map.replace("six", peter, john) ;
@Delabassee @JosePaumard#SE84EE
Map: replaceAll
Replaces all the values from the map, using a l
// the existing map
Map<String, Person> map = ... ;
// key, oldValue
map.replaceAll(
(key, value) -> key + " -> " + value ;
) ;
@Delabassee @JosePaumard#SE84EE
Map: remove
Removes a key / value pair if it’s there
// the existing map
Map<String, Person> map = ... ;
// key, oldValue
map.remove("six", john) ;
@Delabassee @JosePaumard#SE84EE
Map: compute
Computes a value from the existing key / value pair
and a l
// the existing map
Map<String, Person> map = ... ;
// key, oldValue
map.compute(
key,
(key, person) -> key + "::" + person // person can be null
) ;
@Delabassee @JosePaumard#SE84EE
Map: computeIfAbsent
Computes a value from a key that is not in the map
// the existing map
Map<String, Person> map = ... ;
// key, no existing value
map.computeIfAbsent(
key,
key -> person
) ;
@Delabassee @JosePaumard#SE84EE
Map: computeIfPresent
Computes a value from the existing key / value pair
and a l
// the existing map
Map<String, Person> map = ... ;
// key, the existing value
map.computeIfPresent(
key, person,
(key, person) -> newPerson // person cannot be null
) ;
@Delabassee @JosePaumard#SE84EE
Map: compute*
The trick is: these methods return the value, whether it was
there of just created
@Delabassee @JosePaumard#SE84EE
Building maps of maps
Making maps of maps becomes sooo easy!
// the existing map
Map<String, Map<String, Person>> map = ... ;
// key, newValue
map.computeIfAbsent(
"one",
(key, value) -> new HashMap<>()
).put("two", john);
@Delabassee @JosePaumard#SE84EE
Map: merge
Computes the new value from the existing value, the newly
added value and a l
// the existing map
Map<Long, String> map = ... ;
// key, otherValue
map.merge(
key,
otherValue,
(value, otherValue) -> String.join(", ", value, otherValue)
) ;
@Delabassee @JosePaumard#SE84EE
What we might have in 9 (JEP 269)
New patterns to build maps
Map<Integer, String> map =
Map.of(1, "one", 2, "two");
Map<Integer, String> map =
Map.fromEntries(
entry(1, "one"),
entry(2, "two"),
entry(3, "three")
);
Streams
@Delabassee @JosePaumard#SE84EE
What is a Stream?
A new API
A typed interface
A new concept
@Delabassee @JosePaumard#SE84EE
What is a Stream?
A new API
A typed interface
A new concept
Let’s see some code!
@Delabassee @JosePaumard#SE84EE
Readable and efficient patterns
Extract histograms from data
List<Person> people = Arrays.asList();
Map<City, Double> agesByCity =
people.stream()
.filter(p -> p.getAge() > 20)
.collect(
Collectors.groupingBy(
Person::getCity,
Collectors.averagingDouble(Person::getAge)
)
);
@Delabassee @JosePaumard#SE84EE
Readable and efficient patterns
Extract histograms from data
List<Person> people = Arrays.asList();
Map<City, Double> agesByCity =
people.stream()
.filter(p -> p.getAge() > 20)
.collect(
Collectors.groupingBy(
Person::getCity,
Collectors.averagingDouble(Person::getAge)
)
);
@Delabassee @JosePaumard#SE84EE
Readable and efficient patterns
Extract histograms from data
List<Person> people = Arrays.asList();
Map<City, Double> agesByCity =
people.stream()
.filter(p -> p.getAge() > 20)
.collect(
Collectors.groupingBy(
Person::getCity,
Collectors.averagingDouble(Person::getAge)
)
);
@Delabassee @JosePaumard#SE84EE
Readable and efficient patterns
Extract histograms from data
List<Person> people = Arrays.asList();
Map<City, Double> agesByCity =
people.stream()
.filter(p -> p.getAge() > 20)
.collect(
Collectors.groupingBy(
Person::getCity,
Collectors.averagingDouble(Person::getAge)
)
);
@Delabassee @JosePaumard#SE84EE
Readable and efficient patterns
Extract histograms from data
List<Person> people = Arrays.asList();
Map<City, Double> agesByCity =
people.stream()
.filter(p -> p.getAge() > 20)
.collect(
Collectors.groupingBy(
Person::getCity,
Collectors.averagingDouble(Person::getAge)
)
);
@Delabassee @JosePaumard#SE84EE
Readable and efficient patterns
Extract histograms from data
List<Person> people = Arrays.asList();
Map<City, Double> agesByCity =
people.stream()
.filter(p -> p.getAge() > 20)
.collect(
Collectors.groupingBy(
Person::getCity,
Collectors.averagingDouble(Person::getAge)
)
);
@Delabassee @JosePaumard#SE84EE
Building a Stream on a String
Building a Stream on the letters of a String:
String s = "hello";
IntStream stream = s.chars(); // stream on the letters of s
@Delabassee @JosePaumard#SE84EE
Building a Stream on a String
Building a Stream on the letters of a String:
String s = "hello";
IntStream stream = s.chars(); // stream on the letters of s
s.chars() // IntStream
.mapToObj(letter -> (char)letter) // Stream<Character>
.map(Character::toUpperCase)
.forEach(System.out::println); // Prints a Character
> HELLO
@Delabassee @JosePaumard#SE84EE
Build a Stream from a text file
Find the first error line from a log file
// Java 7 : try with resources and use of Paths
Path path = Paths.get("d:", "tmp", "debug.log");
try (Stream<String> stream = Files.lines(path)) {
stream.filter(line -> line.contains("ERROR"))
.findFirst()
.ifPresent(System.out::println);
} catch (IOException ioe) {
// handle the exception
}
@Delabassee @JosePaumard#SE84EE
Build a Stream from a regex
Building a Stream from a regexp
// book is a looooooooong String
Stream<String> words =
Pattern
.compile(" ")
.splitAsStream(book) ;
@Delabassee @JosePaumard#SE84EE
Flatmap: Files.lines + regex
Splitting a text files into words
Stream<String> streamOfLines = Files.lines(path);
Function<String, Stream<String>> splitter =
line -> Pattern.compile(" ").splitAsStream(line);
long numberOfWords =
streamOfLines.flatMap(splitter)
.map(String::toLowerCase)
.distinct()
.count();
@Delabassee @JosePaumard#SE84EE
Why is it important for Java EE?
Given this JSON file
[
{
"name":"Duke",
"gender":"M",
"phones":{
"home":"650‐123‐4567",
"mobile":"650‐111‐2222"
}
}
]
@Delabassee @JosePaumard#SE84EE
Why is it important for Java EE?
And some JSONB magic:
Map<String, Long> names =
contacts.getValue(JsonObject.class).stream()
.filter(x -> "F".equals(x.getString("gender")))
.map(x -> (x.getString("name"))
.collect(
Collectors.groupingBy(
Function.identity(),
Collectors.counting()
)
);
@Delabassee @JosePaumard#SE84EE
Why is it important for Java EE?
We can event collect into a JSon Array
JsonArray names =
contacts.getValue(JsonObject.class).stream()
.filter(x -> "F".equals(x.getString("gender")))
.map(x -> (x.getString("name"))
.collect(
JsonCollectors.toJsonArray()
);
Optional
@Delabassee @JosePaumard#SE84EE
Optional
Optional has been created to tell that this method could return
« no value »
Ex: max(), min()
@Delabassee @JosePaumard#SE84EE
Optional
Optional has been created to tell that this method could return
« no value »
Ex: max(), min(), average()
@Delabassee @JosePaumard#SE84EE
Optional
An Optional is a wrapping type, that can be empty
How can I build one?
Optional<String> opt = Optional.<String>empty() ;
Optional<String> opt = Optional.of("one") ; // not null
Optional<String> opt = Optional.ofNullable(s) ; // may be null
@Delabassee @JosePaumard#SE84EE
Optional
An Optional is a wrapping type, that can be empty
How can I use it?
Optional<String> opt = ... ;
if (opt.isPresent()) {
String s = opt.get() ;
} else {
...
}
@Delabassee @JosePaumard#SE84EE
Optional
An Optional is a wrapping type, that can be empty
How can I use it?
String s = opt.orElse("") ; // this is a default value that
// is valid for our application
Optional<String> opt = ... ;
if (opt.isPresent()) {
String s = opt.get() ;
} else {
...
}
@Delabassee @JosePaumard#SE84EE
Optional
An Optional is a wrapping type, that can be empty
How can I use it?
String s = opt.orElseThrow(MyException::new) ; // lazy initialization
@Delabassee @JosePaumard#SE84EE
Optional: more patterns
An Optional can be seen as a special Stream
with zero or one element
void ifPresent(Consumer<T> consumer) ;
@Delabassee @JosePaumard#SE84EE
Optional: more patterns
An Optional can be seen as a special Stream
with zero or one element
void ifPresent(Consumer<T> consumer) ;
Optional<T> filter(Predicate<T> mapper) ;
@Delabassee @JosePaumard#SE84EE
Optional: more patterns
An Optional can be seen as a special Stream
with zero or one element
void ifPresent(Consumer<T> consumer) ;
Optional<T> filter(Predicate<T> mapper) ;
Optional<U> map(Function<T, U> mapper) ;
@Delabassee @JosePaumard#SE84EE
Optional: more patterns
An Optional can be seen as a special Stream
with zero or one element
void ifPresent(Consumer<T> consumer) ;
Optional<T> filter(Predicate<T> mapper) ;
Optional<U> map(Function<T, U> mapper) ;
Optional<U> flatMap(Function<T, Optional<U>> mapper) ;
@Delabassee @JosePaumard#SE84EE
Optional: new patterns sighted!
public class NewMath {
public static Optional<Double> inv(Double d) {
return d == 0.0d ? Optional.empty() :
Optional.of(1/d) ;
}
public static Optional<Double> sqrt(Double d) {
return d < 0.0d ? Optional.empty() :
Optional.of(Math.sqrt(d)) ;
}
}
@Delabassee @JosePaumard#SE84EE
Optional: new patterns sighted!
List<Double> doubles = Arrays.asList(-1d, 0d, 1d) ;
List<Double> result = new ArrayList<>() ;
doubles.forEach(
d1 -> NewMath.inv(d1) // Optional<Double>
.flatMap(d2 -> NewMath.sqrt(d2)) // Optional<Double>
.ifPresent(result::add)
) ;
doubles : [-1.0, 0.0, 1.0]
result : [1.0]
@Delabassee @JosePaumard#SE84EE
Optional: new patterns sighted!
List<Double> doubles = Arrays.asList(-1d, 0d, 1d) ;
List<Double> result = new ArrayList<>() ;
doubles.forEach(
d1 -> NewMath.inv(d1) // Optional<Double>
.flatMap(d2 -> NewMath.sqrt(d2)) // Optional<Double>
.ifPresent(result::add)
) ;
doubles : [-1.0, 0.0, 1.0]
result : [1.0]
@Delabassee @JosePaumard#SE84EE
Optional: new patterns sighted!
List<Double> doubles = Arrays.asList(-1d, 0d, 1d) ;
List<Double> result = new ArrayList<>() ;
doubles.forEach(
d1 -> NewMath.inv(d1) // Optional<Double>
.flatMap(d2 -> NewMath.sqrt(d2)) // Optional<Double>
.ifPresent(result::add) // Baaaaad pattern 
) ;
doubles : [-1.0, 0.0, 1.0]
result : [1.0]
@Delabassee @JosePaumard#SE84EE
Optional: new patterns sighted!
Function<Double, Optional<Double>> f =
d -> NewMath.inv(d) // Optional<Double>
.flatMap(d -> NewMath.sqrt(d))// Optional<Double>
@Delabassee @JosePaumard#SE84EE
Optional: new patterns sighted!
d -> NewMath.inv(d) // Optional<Double>
.flatMap(NewMath::sqrt) // Optional<Double>
.map(Stream::of) // Optional<Stream<Double>>
@Delabassee @JosePaumard#SE84EE
Optional: new patterns sighted!
d -> NewMath.inv(d) // Optional<Double>
.flatMap(NewMath::sqrt) // Optional<Double>
.map(Stream::of) // Optional<Stream<Double>>
.orElse(Stream.empty()) // Stream<Double>
@Delabassee @JosePaumard#SE84EE
Optional: new patterns sighted!
Function<Double, Stream<Double>> f =
d -> NewMath.inv(d) // Optional<Double>
.flatMap(NewMath::sqrt) // Optional<Double>
.map(Stream::of) // Optional<Stream<Double>>
.orElse(Stream.empty()) ; // Stream<Double>
@Delabassee @JosePaumard#SE84EE
Optional: new patterns sighted!
List<Double> doubles = Arrays.asList(-1d, 0d, 1d) ;
List<Double> result = new ArrayList<>() ;
doubles.stream()
.flatMap(
d -> NewMath.inv(d) // Optional<Double>
.flatMap(NewMath::sqrt) // Optional<Double>
.map(Stream::of) // Optional<Stream<Double>>
.orElse(Stream.empty()) // Stream<Double>
) // Stream<Double>
@Delabassee @JosePaumard#SE84EE
Optional: new patterns sighted!
List<Double> doubles = Arrays.asList(-1d, 0d, 1d) ;
List<Double> result = new ArrayList<>() ;
doubles.stream()
.flatMap(
d -> NewMath.inv(d) // Optional<Double>
.flatMap(NewMath::sqrt) // Optional<Double>
.map(Stream::of) // Optional<Stream<Double>>
.orElse(Stream.empty()) // Stream<Double>
) // Stream<Double>
.collect(Collectors.toList()) ;
@Delabassee @JosePaumard#SE84EE
Optional: new patterns sighted!
List<Double> doubles = Arrays.asList(-1d, 0d, 1d) ;
List<Double> result =
doubles.stream()
.flatMap(
d -> NewMath.inv(d) // Optional<Double>
.flatMap(NewMath::sqrt) // Optional<Double>
.map(Stream::of) // Optional<Stream<Double>>
.orElse(Stream.empty()) // Stream<Double>
) // Stream<Double>
.collect(Collectors.toList()) ;
@Delabassee @JosePaumard#SE84EE
Optional: new patterns sighted!
List<Double> doubles = Arrays.asList(-1d, 0d, 1d) ;
List<Double> result =
doubles.stream().parallel()
.flatMap(
d -> NewMath.inv(d) // Optional<Double>
.flatMap(NewMath::sqrt) // Optional<Double>
.map(Stream::of) // Optional<Stream<Double>>
.orElse(Stream.empty()) // Stream<Double>
) // Stream<Double>
.collect(Collectors.toList()) ;
ConcurrentConcurrent
HashMap
@Delabassee @JosePaumard#SE84EE
ConcurrentHashMap
The old ConcurrentHashMap V7 has been removed
Thread safe
No locking ≠ ConcurrentHashMap V7
New methods (a lot…)
@Delabassee @JosePaumard#SE84EE
ConcurrentHashMap
6000 lines of code
@Delabassee @JosePaumard#SE84EE
ConcurrentHashMap
6000 lines of code
54 member classes
@Delabassee @JosePaumard#SE84EE
ConcurrentHashMap
6000 lines of code
54 member classes
FYI: 58 classes in java.util.concurrent
@Delabassee @JosePaumard#SE84EE
ConcurrentHashMap
6000 lines of code
54 member classes
FYI: 58 classes in java.util.concurrent
New patterns!
@Delabassee @JosePaumard#SE84EE
ConcurrentHashMap
Forget about size()
int count = map.size() ; // should not be used
count = map.mappingCount() ; // new method
@Delabassee @JosePaumard#SE84EE
ConcurrentHashMap
Forget about size()
int count = map.size() ; // should not be used
long count = map.mappingCount() ; // new method
@Delabassee @JosePaumard#SE84EE
ConcurrentHashMap
Search() method
search(), searchKey(), searchValue(), searchEntry()
Returns the 1st element that matches the predicate
ConcurrentHashMap<Integer, String> map = ... ;
map.search(10L, (key, value) -> value.length() < key) ;
@Delabassee @JosePaumard#SE84EE
ConcurrentHashMap
Search() method
search(), searchKey(), searchValue(), searchEntry()
Returns the 1st element that matches the predicate
ConcurrentHashMap<Integer, String> map = ... ;
map.search(10L, (key, value) -> value.length() < key) ;
@Delabassee @JosePaumard#SE84EE
ConcurrentHashMap
Search() method
If there are more than 10 elements, then the search will be
conducted in parallel!
ConcurrentHashMap<Integer, String> map = ... ;
map.search(10L, (key, value) -> value.length() < key) ;
@Delabassee @JosePaumard#SE84EE
ConcurrentHashMap
Search() method
If there are more than 10 elements, then the search will be
conducted in parallel!
One can pass 0 or Long.MAX_VALUE
ConcurrentHashMap<Integer, String> map = ... ;
map.search(10L, (key, value) -> value.length() < key) ;
@Delabassee @JosePaumard#SE84EE
ConcurrentHashMap
ForEach
forEach(), forEachKey(), forEachEntries()
ConcurrentHashMap<Integer, String> map = ... ;
map.forEach(10L,
(key, value) ->
System.out.println(String.join("->", key, value))
) ;
@Delabassee @JosePaumard#SE84EE
ConcurrentHashMap
Reduction
reduce(), reduceKey(), reduceEntries()
ConcurrentHashMap<Integer, String> map = ... ;
map.reduce(10L,
(key, value) -> value.getName(), // transformation
(name1, name2) -> name1.length() > name2.length() ?
name1 : name2) // reduction
) ;
@Delabassee @JosePaumard#SE84EE
No ConcurrentHashSet
But…
Set<String> set = ConcurrentHashMap.newKeySet() ;
@Delabassee @JosePaumard#SE84EE
No ConcurrentHashSet
But…
Creates a concurrent hashmap in which the values are
Boolean.TRUE
Acts as a concurrent set
Set<String> set = ConcurrentHashMap.newKeySet() ;
Parallelism
@Delabassee @JosePaumard#SE84EE
A warning on parallelism
All parallel operations (Streams, ConcurrentHashMap)
take place in the common ForkJoinPool
The common ForkJoinPool takes all the
available cores / CPUs
@Delabassee @JosePaumard#SE84EE
A warning on parallelism
All parallel operations (Streams, ConcurrentHashMap)
take place in the common ForkJoinPool
The common ForkJoinPool takes all the
available cores / CPUs
If you want to preserve your application server:
System.setProperty(
"java.util.concurrent.ForkJoinPool.common.parallelism", "1") ;
Completable
Future
@Delabassee @JosePaumard#SE84EE
CompletableFuture
New addition to j.u.concurrent
Allow to chain asynchronous tasks
Use case: test the asynchronous calls in the Servlet API
@Delabassee @JosePaumard#SE84EE
Creation of an asynchronous task
The Jersey way to create an asynchronous call
@Path("/resource")
public class AsyncResource {
@GET
public void asyncGet(@Suspended final AsyncResponse asyncResponse) {
new Thread(new Runnable() {
public void run() {
String result = longOperation();
asyncResponse.resume(result);
}
}).start();
}
}
@Delabassee @JosePaumard#SE84EE
Creation of an asynchronous task
(let us fix this code, this is Java 8)
@Path("/resource")
public class AsyncResource {
@GET
public void asyncGet(@Suspended final AsyncResponse asyncResponse) {
new Thread(() -> {
String result = longOperation();
asyncResponse.resume(result);
}).start();
}
}
@Delabassee @JosePaumard#SE84EE
How to test it?
We want to check if the result object
is passed to the resume() method of the asyncResponse
It is a very basic test, but tricky to write since we are in an
asynchronous world
We have mocks for that!
@Delabassee @JosePaumard#SE84EE
How to test it?
We can inject a mock AsyncResponse, even mock the result
Then verify the correct interaction:
But we need to verify this once the run() method has been
called…
Mockito.verify(mockAsyncResponse).resume(result);
@Delabassee @JosePaumard#SE84EE
How to test it?
This is where CompletionStage come to the rescue!
@Path("/resource")
public class AsyncResource {
@Inject ExecutorService executor;
@GET
public void asyncGet(@Suspended final AsyncResponse asyncResponse) {
executor.submit(() -> {
String result = longOperation();
asyncResponse.resume(result);
});
}
}
@Delabassee @JosePaumard#SE84EE
How to test it?
@Path("/resource")
public class AsyncResource {
@Inject ExecutorService executor;
@GET
public void asyncGet(@Suspended final AsyncResponse asyncResponse) {
executeAsync(asyncResponse);
}
public CompletableFuture<Void> executeAsync(final AsyncResponse asyncResponse) {
return CompletableFuture.runAsync(() -> {
asyncResponse.resume(longOperation());
}, executor);
}
}
@Delabassee @JosePaumard#SE84EE
How to test it?
AsyncResource asyncResource = new AsyncResource();
asyncResource.executeAsync(mockAsyncResponse); // returns the CompletableFuture
.thenRun(() -> { // then execute this Runnable
Mockito.verify(mockAsyncResponse).resume(result);
}
);
@Delabassee @JosePaumard#SE84EE
How to test it?
Be careful of visibility issues
1) It’s better to run this in the same thread
2) Since the mocks are used and checked in this thread,
create them in this thread too
@Delabassee @JosePaumard#SE84EE
How to test it?
So the complete pattern becomes this one
1) First we create our mocks
String result = Mockito.mock(String.class);
AsyncResponse response = Mockito.mock(AsyncResponse.class);
Runnable train = () -> Mockito.doReturn(result).when(response).longOperation();
Runnable verify = () -> Mockito.verify(response).resume(result);
@Delabassee @JosePaumard#SE84EE
How to test it?
So the complete pattern becomes this one
2) Then we create the call & verify
Runnable callAndVerify = () -> {
asyncResource.executeAsync(response).thenRun(verify);
}
@Delabassee @JosePaumard#SE84EE
How to test it?
So the complete pattern becomes this one
3) Then we create the task
ExecutorService executor = Executors.newSingleThreadExecutor();
AsynResource asyncResource = new AsyncResource();
asyncResource.setExecutorService(executor);
CompletableFuture
.runAsync(train, executor) // this trains our mocks
.thenRun(asyncVerify); // this verifies our mocks
@Delabassee @JosePaumard#SE84EE
How to test it?
Since a CompletableFuture is also a Future, we can fail
with a timeout if the test does not complete fast enough
ExecutorService executor = Executors.newSingleThreadExecutor();
AsynResource asyncResource = new AsyncResource();
asyncResource.setExecutorService(executor);
CompletableFuture
.runAsync(train, executor) // this trains our mocks
.thenRun(asyncVerify) // this verifies our mocks
.get(10, TimeUnit.SECONDS);
@Delabassee @JosePaumard#SE84EE
Thank you!
@Delabasee @JosePaumard
#SE84EE

More Related Content

What's hot

Java 8, Streams & Collectors, patterns, performances and parallelization
Java 8, Streams & Collectors, patterns, performances and parallelizationJava 8, Streams & Collectors, patterns, performances and parallelization
Java 8, Streams & Collectors, patterns, performances and parallelizationJosé Paumard
 
Lambdas and Streams Master Class Part 2
Lambdas and Streams Master Class Part 2Lambdas and Streams Master Class Part 2
Lambdas and Streams Master Class Part 2José Paumard
 
Going reactive in java
Going reactive in javaGoing reactive in java
Going reactive in javaJosé Paumard
 
Java 8 Streams and Rx Java Comparison
Java 8 Streams and Rx Java ComparisonJava 8 Streams and Rx Java Comparison
Java 8 Streams and Rx Java ComparisonJosé Paumard
 
The Sincerest Form of Flattery
The Sincerest Form of FlatteryThe Sincerest Form of Flattery
The Sincerest Form of FlatteryJosé Paumard
 
Java 8 Stream API and RxJava Comparison
Java 8 Stream API and RxJava ComparisonJava 8 Stream API and RxJava Comparison
Java 8 Stream API and RxJava ComparisonJosé Paumard
 
Autumn collection JavaOne 2014
Autumn collection JavaOne 2014Autumn collection JavaOne 2014
Autumn collection JavaOne 2014José Paumard
 
Collectors in the Wild
Collectors in the WildCollectors in the Wild
Collectors in the WildJosé Paumard
 
Ast transformations
Ast transformationsAst transformations
Ast transformationsHamletDRC
 
Building native Android applications with Mirah and Pindah
Building native Android applications with Mirah and PindahBuilding native Android applications with Mirah and Pindah
Building native Android applications with Mirah and PindahNick Plante
 
Currying and Partial Function Application (PFA)
Currying and Partial Function Application (PFA)Currying and Partial Function Application (PFA)
Currying and Partial Function Application (PFA)Dhaval Dalal
 
Lean & Mean Tokyo Cabinet Recipes (with Lua) - FutureRuby '09
Lean & Mean Tokyo Cabinet Recipes (with Lua) - FutureRuby '09Lean & Mean Tokyo Cabinet Recipes (with Lua) - FutureRuby '09
Lean & Mean Tokyo Cabinet Recipes (with Lua) - FutureRuby '09Ilya Grigorik
 
AST Transformations
AST TransformationsAST Transformations
AST TransformationsHamletDRC
 
Design Patterns - Compiler Case Study - Hands-on Examples
Design Patterns - Compiler Case Study - Hands-on ExamplesDesign Patterns - Compiler Case Study - Hands-on Examples
Design Patterns - Compiler Case Study - Hands-on ExamplesGanesh Samarthyam
 
using python module: doctest
using python module: doctestusing python module: doctest
using python module: doctestmitnk
 
DRYing to Monad in Java8
DRYing to Monad in Java8DRYing to Monad in Java8
DRYing to Monad in Java8Dhaval Dalal
 

What's hot (20)

Java 8, Streams & Collectors, patterns, performances and parallelization
Java 8, Streams & Collectors, patterns, performances and parallelizationJava 8, Streams & Collectors, patterns, performances and parallelization
Java 8, Streams & Collectors, patterns, performances and parallelization
 
Lambdas and Streams Master Class Part 2
Lambdas and Streams Master Class Part 2Lambdas and Streams Master Class Part 2
Lambdas and Streams Master Class Part 2
 
Going reactive in java
Going reactive in javaGoing reactive in java
Going reactive in java
 
Java 8 Streams and Rx Java Comparison
Java 8 Streams and Rx Java ComparisonJava 8 Streams and Rx Java Comparison
Java 8 Streams and Rx Java Comparison
 
Free your lambdas
Free your lambdasFree your lambdas
Free your lambdas
 
The Sincerest Form of Flattery
The Sincerest Form of FlatteryThe Sincerest Form of Flattery
The Sincerest Form of Flattery
 
Java 8 Stream API and RxJava Comparison
Java 8 Stream API and RxJava ComparisonJava 8 Stream API and RxJava Comparison
Java 8 Stream API and RxJava Comparison
 
Autumn collection JavaOne 2014
Autumn collection JavaOne 2014Autumn collection JavaOne 2014
Autumn collection JavaOne 2014
 
Java Full Throttle
Java Full ThrottleJava Full Throttle
Java Full Throttle
 
Collectors in the Wild
Collectors in the WildCollectors in the Wild
Collectors in the Wild
 
Core Java - Quiz Questions - Bug Hunt
Core Java - Quiz Questions - Bug HuntCore Java - Quiz Questions - Bug Hunt
Core Java - Quiz Questions - Bug Hunt
 
Ast transformations
Ast transformationsAst transformations
Ast transformations
 
Building native Android applications with Mirah and Pindah
Building native Android applications with Mirah and PindahBuilding native Android applications with Mirah and Pindah
Building native Android applications with Mirah and Pindah
 
Currying and Partial Function Application (PFA)
Currying and Partial Function Application (PFA)Currying and Partial Function Application (PFA)
Currying and Partial Function Application (PFA)
 
Lean & Mean Tokyo Cabinet Recipes (with Lua) - FutureRuby '09
Lean & Mean Tokyo Cabinet Recipes (with Lua) - FutureRuby '09Lean & Mean Tokyo Cabinet Recipes (with Lua) - FutureRuby '09
Lean & Mean Tokyo Cabinet Recipes (with Lua) - FutureRuby '09
 
AST Transformations
AST TransformationsAST Transformations
AST Transformations
 
Design Patterns - Compiler Case Study - Hands-on Examples
Design Patterns - Compiler Case Study - Hands-on ExamplesDesign Patterns - Compiler Case Study - Hands-on Examples
Design Patterns - Compiler Case Study - Hands-on Examples
 
using python module: doctest
using python module: doctestusing python module: doctest
using python module: doctest
 
DRYing to Monad in Java8
DRYing to Monad in Java8DRYing to Monad in Java8
DRYing to Monad in Java8
 
Java 8 Stream API (Valdas Zigas)
Java 8 Stream API (Valdas Zigas)Java 8 Stream API (Valdas Zigas)
Java 8 Stream API (Valdas Zigas)
 

Similar to Java SE 8 for Java EE developers

Introduction to unit testing
Introduction to unit testingIntroduction to unit testing
Introduction to unit testingArtem Shoobovych
 
SoTWLG Intro to Code Bootcamps 2016 (Roger Nesbitt)
SoTWLG Intro to Code Bootcamps 2016 (Roger Nesbitt)SoTWLG Intro to Code Bootcamps 2016 (Roger Nesbitt)
SoTWLG Intro to Code Bootcamps 2016 (Roger Nesbitt)ruthmcdavitt
 
What did you miss in Java from 9-13?
What did you miss in Java from 9-13?What did you miss in Java from 9-13?
What did you miss in Java from 9-13?relix1988
 
Advanced Perl Techniques
Advanced Perl TechniquesAdvanced Perl Techniques
Advanced Perl TechniquesDave Cross
 
Introducere In Java Jx
Introducere In Java JxIntroducere In Java Jx
Introducere In Java Jxdanielnastase
 
05 status-codes
05 status-codes05 status-codes
05 status-codessnopteck
 
Implementing Comet using PHP
Implementing Comet using PHPImplementing Comet using PHP
Implementing Comet using PHPKing Foo
 
Going crazy with Node.JS and CakePHP
Going crazy with Node.JS and CakePHPGoing crazy with Node.JS and CakePHP
Going crazy with Node.JS and CakePHPMariano Iglesias
 
Designing CakePHP plugins for consuming APIs
Designing CakePHP plugins for consuming APIsDesigning CakePHP plugins for consuming APIs
Designing CakePHP plugins for consuming APIsNeil Crookes
 
Spiffy Applications With JavaScript
Spiffy Applications With JavaScriptSpiffy Applications With JavaScript
Spiffy Applications With JavaScriptMark Casias
 
Dealing with Legacy Perl Code - Peter Scott
Dealing with Legacy Perl Code - Peter ScottDealing with Legacy Perl Code - Peter Scott
Dealing with Legacy Perl Code - Peter ScottO'Reilly Media
 
Advanced Javascript Unit Testing
Advanced Javascript Unit TestingAdvanced Javascript Unit Testing
Advanced Javascript Unit TestingLars Thorup
 
Leverage CompletableFutures to handle async queries. DevNexus 2022
Leverage CompletableFutures to handle async queries. DevNexus 2022Leverage CompletableFutures to handle async queries. DevNexus 2022
Leverage CompletableFutures to handle async queries. DevNexus 2022David Gómez García
 
#SPUG - Legacy applications
#SPUG - Legacy applications#SPUG - Legacy applications
#SPUG - Legacy applicationsPiotr Pasich
 
Introducing Modern Perl
Introducing Modern PerlIntroducing Modern Perl
Introducing Modern PerlDave Cross
 
Spark with Elasticsearch - umd version 2014
Spark with Elasticsearch - umd version 2014Spark with Elasticsearch - umd version 2014
Spark with Elasticsearch - umd version 2014Holden Karau
 

Similar to Java SE 8 for Java EE developers (20)

Introduction to unit testing
Introduction to unit testingIntroduction to unit testing
Introduction to unit testing
 
SoTWLG Intro to Code Bootcamps 2016 (Roger Nesbitt)
SoTWLG Intro to Code Bootcamps 2016 (Roger Nesbitt)SoTWLG Intro to Code Bootcamps 2016 (Roger Nesbitt)
SoTWLG Intro to Code Bootcamps 2016 (Roger Nesbitt)
 
What did you miss in Java from 9-13?
What did you miss in Java from 9-13?What did you miss in Java from 9-13?
What did you miss in Java from 9-13?
 
Java 8 Date and Time API
Java 8 Date and Time APIJava 8 Date and Time API
Java 8 Date and Time API
 
Advanced Perl Techniques
Advanced Perl TechniquesAdvanced Perl Techniques
Advanced Perl Techniques
 
Introducere In Java Jx
Introducere In Java JxIntroducere In Java Jx
Introducere In Java Jx
 
05 status-codes
05 status-codes05 status-codes
05 status-codes
 
Javaslang @ Devoxx
Javaslang @ DevoxxJavaslang @ Devoxx
Javaslang @ Devoxx
 
Implementing Comet using PHP
Implementing Comet using PHPImplementing Comet using PHP
Implementing Comet using PHP
 
Going crazy with Node.JS and CakePHP
Going crazy with Node.JS and CakePHPGoing crazy with Node.JS and CakePHP
Going crazy with Node.JS and CakePHP
 
Designing CakePHP plugins for consuming APIs
Designing CakePHP plugins for consuming APIsDesigning CakePHP plugins for consuming APIs
Designing CakePHP plugins for consuming APIs
 
Spiffy Applications With JavaScript
Spiffy Applications With JavaScriptSpiffy Applications With JavaScript
Spiffy Applications With JavaScript
 
Dealing with Legacy Perl Code - Peter Scott
Dealing with Legacy Perl Code - Peter ScottDealing with Legacy Perl Code - Peter Scott
Dealing with Legacy Perl Code - Peter Scott
 
SlideShare Instant
SlideShare InstantSlideShare Instant
SlideShare Instant
 
SlideShare Instant
SlideShare InstantSlideShare Instant
SlideShare Instant
 
Advanced Javascript Unit Testing
Advanced Javascript Unit TestingAdvanced Javascript Unit Testing
Advanced Javascript Unit Testing
 
Leverage CompletableFutures to handle async queries. DevNexus 2022
Leverage CompletableFutures to handle async queries. DevNexus 2022Leverage CompletableFutures to handle async queries. DevNexus 2022
Leverage CompletableFutures to handle async queries. DevNexus 2022
 
#SPUG - Legacy applications
#SPUG - Legacy applications#SPUG - Legacy applications
#SPUG - Legacy applications
 
Introducing Modern Perl
Introducing Modern PerlIntroducing Modern Perl
Introducing Modern Perl
 
Spark with Elasticsearch - umd version 2014
Spark with Elasticsearch - umd version 2014Spark with Elasticsearch - umd version 2014
Spark with Elasticsearch - umd version 2014
 

More from José Paumard

Loom Virtual Threads in the JDK 19
Loom Virtual Threads in the JDK 19Loom Virtual Threads in the JDK 19
Loom Virtual Threads in the JDK 19José Paumard
 
From Java 11 to 17 and beyond.pdf
From Java 11 to 17 and beyond.pdfFrom Java 11 to 17 and beyond.pdf
From Java 11 to 17 and beyond.pdfJosé Paumard
 
The Future of Java: Records, Sealed Classes and Pattern Matching
The Future of Java: Records, Sealed Classes and Pattern MatchingThe Future of Java: Records, Sealed Classes and Pattern Matching
The Future of Java: Records, Sealed Classes and Pattern MatchingJosé Paumard
 
Deep Dive Java 17 Devoxx UK
Deep Dive Java 17 Devoxx UKDeep Dive Java 17 Devoxx UK
Deep Dive Java 17 Devoxx UKJosé Paumard
 
Designing functional and fluent API: application to some GoF patterns
Designing functional and fluent API: application to some GoF patternsDesigning functional and fluent API: application to some GoF patterns
Designing functional and fluent API: application to some GoF patternsJosé Paumard
 
The Sincerest Form of Flattery
The Sincerest Form of FlatteryThe Sincerest Form of Flattery
The Sincerest Form of FlatteryJosé Paumard
 
Designing functional and fluent API: example of the Visitor Pattern
Designing functional and fluent API: example of the Visitor PatternDesigning functional and fluent API: example of the Visitor Pattern
Designing functional and fluent API: example of the Visitor PatternJosé Paumard
 
Construire son JDK en 10 étapes
Construire son JDK en 10 étapesConstruire son JDK en 10 étapes
Construire son JDK en 10 étapesJosé Paumard
 
Java Keeps Throttling Up!
Java Keeps Throttling Up!Java Keeps Throttling Up!
Java Keeps Throttling Up!José Paumard
 
Asynchronous Systems with Fn Flow
Asynchronous Systems with Fn FlowAsynchronous Systems with Fn Flow
Asynchronous Systems with Fn FlowJosé Paumard
 
JAX-RS and CDI Bike the (Reactive) Bridge
JAX-RS and CDI Bike the (Reactive) BridgeJAX-RS and CDI Bike the (Reactive) Bridge
JAX-RS and CDI Bike the (Reactive) BridgeJosé Paumard
 
JAX RS and CDI bike the reactive bridge
JAX RS and CDI bike the reactive bridgeJAX RS and CDI bike the reactive bridge
JAX RS and CDI bike the reactive bridgeJosé Paumard
 
L'API Collector dans tous ses états
L'API Collector dans tous ses étatsL'API Collector dans tous ses états
L'API Collector dans tous ses étatsJosé Paumard
 
Linked to ArrayList: the full story
Linked to ArrayList: the full storyLinked to ArrayList: the full story
Linked to ArrayList: the full storyJosé Paumard
 
ArrayList et LinkedList sont dans un bateau
ArrayList et LinkedList sont dans un bateauArrayList et LinkedList sont dans un bateau
ArrayList et LinkedList sont dans un bateauJosé Paumard
 
API Asynchrones en Java 8
API Asynchrones en Java 8API Asynchrones en Java 8
API Asynchrones en Java 8José Paumard
 
Les Streams sont parmi nous
Les Streams sont parmi nousLes Streams sont parmi nous
Les Streams sont parmi nousJosé Paumard
 

More from José Paumard (18)

Loom Virtual Threads in the JDK 19
Loom Virtual Threads in the JDK 19Loom Virtual Threads in the JDK 19
Loom Virtual Threads in the JDK 19
 
From Java 11 to 17 and beyond.pdf
From Java 11 to 17 and beyond.pdfFrom Java 11 to 17 and beyond.pdf
From Java 11 to 17 and beyond.pdf
 
The Future of Java: Records, Sealed Classes and Pattern Matching
The Future of Java: Records, Sealed Classes and Pattern MatchingThe Future of Java: Records, Sealed Classes and Pattern Matching
The Future of Java: Records, Sealed Classes and Pattern Matching
 
Deep Dive Java 17 Devoxx UK
Deep Dive Java 17 Devoxx UKDeep Dive Java 17 Devoxx UK
Deep Dive Java 17 Devoxx UK
 
Designing functional and fluent API: application to some GoF patterns
Designing functional and fluent API: application to some GoF patternsDesigning functional and fluent API: application to some GoF patterns
Designing functional and fluent API: application to some GoF patterns
 
The Sincerest Form of Flattery
The Sincerest Form of FlatteryThe Sincerest Form of Flattery
The Sincerest Form of Flattery
 
Designing functional and fluent API: example of the Visitor Pattern
Designing functional and fluent API: example of the Visitor PatternDesigning functional and fluent API: example of the Visitor Pattern
Designing functional and fluent API: example of the Visitor Pattern
 
Construire son JDK en 10 étapes
Construire son JDK en 10 étapesConstruire son JDK en 10 étapes
Construire son JDK en 10 étapes
 
Java Keeps Throttling Up!
Java Keeps Throttling Up!Java Keeps Throttling Up!
Java Keeps Throttling Up!
 
Asynchronous Systems with Fn Flow
Asynchronous Systems with Fn FlowAsynchronous Systems with Fn Flow
Asynchronous Systems with Fn Flow
 
JAX-RS and CDI Bike the (Reactive) Bridge
JAX-RS and CDI Bike the (Reactive) BridgeJAX-RS and CDI Bike the (Reactive) Bridge
JAX-RS and CDI Bike the (Reactive) Bridge
 
Streams in the wild
Streams in the wildStreams in the wild
Streams in the wild
 
JAX RS and CDI bike the reactive bridge
JAX RS and CDI bike the reactive bridgeJAX RS and CDI bike the reactive bridge
JAX RS and CDI bike the reactive bridge
 
L'API Collector dans tous ses états
L'API Collector dans tous ses étatsL'API Collector dans tous ses états
L'API Collector dans tous ses états
 
Linked to ArrayList: the full story
Linked to ArrayList: the full storyLinked to ArrayList: the full story
Linked to ArrayList: the full story
 
ArrayList et LinkedList sont dans un bateau
ArrayList et LinkedList sont dans un bateauArrayList et LinkedList sont dans un bateau
ArrayList et LinkedList sont dans un bateau
 
API Asynchrones en Java 8
API Asynchrones en Java 8API Asynchrones en Java 8
API Asynchrones en Java 8
 
Les Streams sont parmi nous
Les Streams sont parmi nousLes Streams sont parmi nous
Les Streams sont parmi nous
 

Recently uploaded

Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designMIPLM
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptxSherlyMaeNeri
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
 
Quarter 4 Peace-education.pptx Catch Up Friday
Quarter 4 Peace-education.pptx Catch Up FridayQuarter 4 Peace-education.pptx Catch Up Friday
Quarter 4 Peace-education.pptx Catch Up FridayMakMakNepo
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
ROOT CAUSE ANALYSIS PowerPoint Presentation
ROOT CAUSE ANALYSIS PowerPoint PresentationROOT CAUSE ANALYSIS PowerPoint Presentation
ROOT CAUSE ANALYSIS PowerPoint PresentationAadityaSharma884161
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementmkooblal
 
Atmosphere science 7 quarter 4 .........
Atmosphere science 7 quarter 4 .........Atmosphere science 7 quarter 4 .........
Atmosphere science 7 quarter 4 .........LeaCamillePacle
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 

Recently uploaded (20)

Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-design
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
Raw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptxRaw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptx
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptx
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
 
Quarter 4 Peace-education.pptx Catch Up Friday
Quarter 4 Peace-education.pptx Catch Up FridayQuarter 4 Peace-education.pptx Catch Up Friday
Quarter 4 Peace-education.pptx Catch Up Friday
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
ROOT CAUSE ANALYSIS PowerPoint Presentation
ROOT CAUSE ANALYSIS PowerPoint PresentationROOT CAUSE ANALYSIS PowerPoint Presentation
ROOT CAUSE ANALYSIS PowerPoint Presentation
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of management
 
Atmosphere science 7 quarter 4 .........
Atmosphere science 7 quarter 4 .........Atmosphere science 7 quarter 4 .........
Atmosphere science 7 quarter 4 .........
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 

Java SE 8 for Java EE developers