public DirectionsApiRequest optimizeWaypoints(boolean optimize) {
    optimizeWaypoints = optimize;
    if (waypoints != null) {
      return waypoints(waypoints);
    } else {
      return this;
    }
  }
Allow the Directions service to optimize the provided route by rearranging the waypoints in a
more efficient order.

@param optimize Whether to optimize waypoints.
@return Returns this {@code DirectionsApiRequest} for call chaining.
src/main/java/com/google/maps/DirectionsApiRequest.java