I have an instance of OptionalLong. But one of my libraries requires an Optional as a parameter.
OptionalLong
Optional
How can I convert my Option
Option
I don't know simpler solutions but this will do what you need.
OptionalLong secondScreenHeight = OptionalLong.of(32l); Optional optional = secondScreenHeight.isPresent() ? Optional.of(secondSceenHeight.getAsLong()) : Optional.empty(); api.setHeight(optional);