code: public static <T> Optional<T> firstInList(List<T> list) {
          return list.isEmpty() ? Optional.empty() : Optional.ofNullable(list.get(0));
      }
docs: Adapter to create an Optional out of the first element of a List. If the list is empty, we get
  an empty optional. Also, if the first element is null, return an empty optional.
  
  @param <T> the type of objects in the list
  @param list the list to look at
  @return the possible first element in list