Is it possible to transform this code to a Java 8 Optional one-line expression?
long lastPollTime; if (object != null) { lastPollTime = object.getTime();
you can do like below with java 8
long lastPollTime=Optional.ofNullable(object).isPresent()?object.getTime():0;
or without using java8 like this
long lastPollTime = object != null ?object.getTime():0;