@Override
  protected void validateRequest() {
    if (!params().containsKey("origins")) {
      throw new IllegalArgumentException("Request must contain 'origins'");
    }
    if (!params().containsKey("destinations")) {
      throw new IllegalArgumentException("Request must contain 'destinations'");
    }
    if (params().containsKey("arrival_time") && params().containsKey("departure_time")) {
      throw new IllegalArgumentException(
          "Transit request must not contain both a departureTime and an arrivalTime");
    }
  }
A request to the Distance Matrix API.
src/main/java/com/google/maps/DistanceMatrixApiRequest.java