‘OptionalDouble.getAsDouble()’ without ‘isPresent()’ check

I’ve seen a bunch of solutions for this question but no matter what I try, IDEA still reports an error. Consider the following block: double testDouble= customClass.stream() .mapToDouble(…

How to properly unwrap an optional in Java?

I am learning the basics of Java and I am exploring Optionals and abstract classes so I came across the following issue, I have this code import java.util.Optional; public abstract class Animal { …

Using Java Optional in Kotlin DTOs

Currently I’m using Java 8’s Optional in my Kotlin DTOs as follows: class dto { var prop1: String? = null var prop2: Optional? = null } The purpose of it is that for some …

MapStruct – Can’t map property Optional to LocalDate

NOTE: This is unlike other questions on StackOverflow because they resolve this issue by mapping the two classes manually. Since ScheduleSource and ScheduleTarget are exactly the same classes, I want …

Monads with Java 8

In the interests of helping to understand what a monad is, can someone provide an example using java ? Are they possible ? Lambda expressions are possible using java if you download the pre-release …