Might be refactored to this.total = total == -1 ? Optional.<Integer>absent() : Optional.of(total);