I have a Option<Object>
from which i am trying to get long value. But this does not work. I tried the below steps but could not get the value as it shows compiler error. Please help.
//#1
Option<Object> expireTimestamp = offsetAndMetadata.expireTimestamp();
expireTimestamp.getOrElse(0L);
Also tried
Option<Object> expireTimestamp = offsetAndMetadata.expireTimestamp();
expireTimestamp.getOrElse(new Long(0));
//#2
Option<Long> expireTimestamp = (Option<Long>) offsetAndMetadata.expireTimestamp();
The method getOrElse(Function0) in the type Option is not applicable for the arguments (long)
As, commented by Thilo, I tried the below code and it worked
offsetAndMetadata.expireTimestamp().getOrElse(() -> 0L)