public static <E,R>R ifelse(Optional<E> condition,Function<E,R> trueMap,R falseValue){
  if (condition.isPresent()) {
    return trueMap.apply(condition.get());
  }
 else {
    return falseValue;
  }
}

public static < E , R > R ifelse ( Optional < E > condition , Function < E , R > trueMap , R falseValue ) { if ( condition . isPresent ( ) ) { return trueMap . apply ( condition . get ( ) ) ; } else { return falseValue ; } }
if the condition is present , the true - function will be called with its value and the result will be returned . else the false - value will be returned .
