Skip to content

Commit

Permalink
Applying google-java-format to the codebase.
Browse files Browse the repository at this point in the history
This is a first attempt at splitting up #283
  • Loading branch information
domesticmouse committed Jul 17, 2017
1 parent 2ecc218 commit 5b7d373
Show file tree
Hide file tree
Showing 146 changed files with 15,680 additions and 14,499 deletions.
30 changes: 12 additions & 18 deletions src/main/java/com/google/maps/DirectionsApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,20 @@
* text strings (e.g. "Chicago, IL" or "Darwin, NT, Australia") or as latitude/longitude
* coordinates. The Directions API can return multi-part directions using a series of waypoints.
*
* <p>See <a href="https://developers.google.com/maps/documentation/directions/intro">documentation</a>.
* <p>See <a
* href="https://developers.google.com/maps/documentation/directions/intro">documentation</a>.
*/
public class DirectionsApi {
static final ApiConfig API_CONFIG = new ApiConfig("/maps/api/directions/json");

private DirectionsApi() {
}
private DirectionsApi() {}

public static DirectionsApiRequest newRequest(GeoApiContext context) {
return new DirectionsApiRequest(context);
}

public static DirectionsApiRequest getDirections(GeoApiContext context,
String origin,
String destination) {
public static DirectionsApiRequest getDirections(
GeoApiContext context, String origin, String destination) {
return new DirectionsApiRequest(context).origin(origin).destination(destination);
}

Expand Down Expand Up @@ -78,28 +77,23 @@ public ApiException getError() {

/**
* Directions may be calculated that adhere to certain restrictions. This is configured by calling
* {@link com.google.maps.DirectionsApiRequest#avoid} or {@link com.google.maps.DistanceMatrixApiRequest#avoid}.
* {@link com.google.maps.DirectionsApiRequest#avoid} or {@link
* com.google.maps.DistanceMatrixApiRequest#avoid}.
*
* @see <a href="https://developers.google.com/maps/documentation/directions/intro#Restrictions">
* Restrictions in the Directions API</a>
* Restrictions in the Directions API</a>
* @see <a href="https://developers.google.com/maps/documentation/distancematrix/#Restrictions">
* Restrictions in the Distance Matrix API</a>
* Restrictions in the Distance Matrix API</a>
*/
public enum RouteRestriction implements UrlValue {

/**
* {@code TOLLS} indicates that the calculated route should avoid toll roads/bridges.
*/
/** {@code TOLLS} indicates that the calculated route should avoid toll roads/bridges. */
TOLLS("tolls"),

/**
* {@code HIGHWAYS} indicates that the calculated route should avoid highways.
*/
/** {@code HIGHWAYS} indicates that the calculated route should avoid highways. */
HIGHWAYS("highways"),

/**
* {@code FERRIES} indicates that the calculated route should avoid ferries.
*/
/** {@code FERRIES} indicates that the calculated route should avoid ferries. */
FERRIES("ferries");

private final String restriction;
Expand Down
37 changes: 13 additions & 24 deletions src/main/java/com/google/maps/DirectionsApiRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,18 @@

package com.google.maps;

import static com.google.maps.internal.StringJoin.join;

import com.google.maps.model.DirectionsResult;
import com.google.maps.model.LatLng;
import com.google.maps.model.TrafficModel;
import com.google.maps.model.TransitMode;
import com.google.maps.model.TransitRoutingPreference;
import com.google.maps.model.TravelMode;
import com.google.maps.model.Unit;

import org.joda.time.ReadableInstant;

/**
* Request for the Directions API.
*/
import static com.google.maps.internal.StringJoin.join;

/** Request for the Directions API. */
public class DirectionsApiRequest
extends PendingResultBase<DirectionsResult, DirectionsApiRequest, DirectionsApi.Response> {

Expand All @@ -54,8 +51,8 @@ protected void validateRequest() {
"Transit request must not contain both a departureTime and an arrivalTime");
}
if (params().containsKey("traffic_model") && !params().containsKey("departure_time")) {
throw new IllegalArgumentException("Specifying a traffic model requires that departure time"
+ " be provided.");
throw new IllegalArgumentException(
"Specifying a traffic model requires that departure time" + " be provided.");
}
}

Expand All @@ -79,16 +76,12 @@ public DirectionsApiRequest destination(String destination) {
return param("destination", destination);
}

/**
* The origin, as a latitude,longitude location.
*/
/** The origin, as a latitude,longitude location. */
public DirectionsApiRequest origin(LatLng origin) {
return origin(origin.toString());
}

/**
* The destination, as a latitude,longitude location.
*/
/** The destination, as a latitude,longitude location. */
public DirectionsApiRequest destination(LatLng destination) {
return destination(destination.toString());
}
Expand All @@ -108,15 +101,13 @@ public DirectionsApiRequest mode(TravelMode mode) {
* Indicates that the calculated route(s) should avoid the indicated features.
*
* @param restrictions one or more of {@link DirectionsApi.RouteRestriction#TOLLS}, {@link
* DirectionsApi.RouteRestriction#HIGHWAYS}, {@link DirectionsApi.RouteRestriction#FERRIES}
* DirectionsApi.RouteRestriction#HIGHWAYS}, {@link DirectionsApi.RouteRestriction#FERRIES}
*/
public DirectionsApiRequest avoid(DirectionsApi.RouteRestriction... restrictions) {
return param("avoid", join('|', restrictions));
}

/**
* Specifies the unit system to use when displaying results.
*/
/** Specifies the unit system to use when displaying results. */
public DirectionsApiRequest units(Unit units) {
return param("units", units);
}
Expand Down Expand Up @@ -154,8 +145,9 @@ public DirectionsApiRequest departureTime(ReadableInstant time) {
* which will be geocoded. Waypoints are only supported for driving, walking and bicycling
* directions.
*
* <p>For more information on waypoints, see <a href="https://developers.google.com/maps/documentation/directions/intro#Waypoints">
* Using Waypoints in Routes</a>.
* <p>For more information on waypoints, see <a
* href="https://developers.google.com/maps/documentation/directions/intro#Waypoints">Using
* Waypoints in Routes</a>.
*/
public DirectionsApiRequest waypoints(String... waypoints) {
this.waypoints = waypoints;
Expand All @@ -168,9 +160,7 @@ public DirectionsApiRequest waypoints(String... waypoints) {
}
}

/**
* The list of waypoints as latitude,longitude locations.
*/
/** The list of waypoints as latitude,longitude locations. */
public DirectionsApiRequest waypoints(LatLng... waypoints) {
if (waypoints == null) {
return this;
Expand Down Expand Up @@ -232,5 +222,4 @@ public DirectionsApiRequest transitRoutingPreference(TransitRoutingPreference pr
public DirectionsApiRequest trafficModel(TrafficModel trafficModel) {
return param("traffic_model", trafficModel);
}

}
11 changes: 4 additions & 7 deletions src/main/java/com/google/maps/DistanceMatrixApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,19 @@
* a map. Use of the service in an application that doesn't display a Google map is prohibited.
*
* @see <a href="https://developers.google.com/maps/documentation/distancematrix/">Distance Matrix
* Documentation</a>
* Documentation</a>
*/
public class DistanceMatrixApi {
static final ApiConfig API_CONFIG = new ApiConfig("/maps/api/distancematrix/json");

private DistanceMatrixApi() {
}
private DistanceMatrixApi() {}

public static DistanceMatrixApiRequest newRequest(GeoApiContext context) {
return new DistanceMatrixApiRequest(context);
}

public static DistanceMatrixApiRequest getDistanceMatrix(GeoApiContext context, String[] origins,
String[] destinations) {
public static DistanceMatrixApiRequest getDistanceMatrix(
GeoApiContext context, String[] origins, String[] destinations) {
return newRequest(context).origins(origins).destinations(destinations);
}

Expand Down Expand Up @@ -79,6 +78,4 @@ public DistanceMatrix getResult() {
return new DistanceMatrix(originAddresses, destinationAddresses, rows);
}
}


}
50 changes: 24 additions & 26 deletions src/main/java/com/google/maps/DistanceMatrixApiRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,20 @@

package com.google.maps;

import static com.google.maps.internal.StringJoin.join;

import com.google.maps.DirectionsApi.RouteRestriction;
import com.google.maps.DistanceMatrixApi.Response;
import com.google.maps.model.DistanceMatrix;
import com.google.maps.model.LatLng;
import com.google.maps.model.TrafficModel;
import com.google.maps.model.TransitMode;
import com.google.maps.model.TransitRoutingPreference;
import com.google.maps.model.TravelMode;
import com.google.maps.model.Unit;
import com.google.maps.model.TrafficModel;

import org.joda.time.ReadableInstant;

/**
* A request to the Distance Matrix API.
*/
import static com.google.maps.internal.StringJoin.join;

/** A request to the Distance Matrix API. */
public class DistanceMatrixApiRequest
extends PendingResultBase<DistanceMatrix, DistanceMatrixApiRequest, Response> {

Expand Down Expand Up @@ -73,7 +70,6 @@ public DistanceMatrixApiRequest origins(LatLng... points) {
return param("origins", join('|', points));
}


/**
* One or more addresses to which to calculate distance and time. The service will geocode the
* string and convert it to a latitude/longitude coordinate to calculate directions.
Expand All @@ -96,10 +92,10 @@ public DistanceMatrixApiRequest destinations(LatLng... points) {
/**
* Specifies the mode of transport to use when calculating directions.
*
* <p>Note that Distance Matrix requests only support {@link TravelMode#DRIVING},
* {@link TravelMode#WALKING} and {@link TravelMode#BICYCLING}.
* @param mode One of the travel modes supported by the Distance Matrix API.
* <p>Note that Distance Matrix requests only support {@link TravelMode#DRIVING}, {@link
* TravelMode#WALKING} and {@link TravelMode#BICYCLING}.
*
* @param mode One of the travel modes supported by the Distance Matrix API.
*/
public DistanceMatrixApiRequest mode(TravelMode mode) {
if (TravelMode.DRIVING.equals(mode)
Expand All @@ -108,15 +104,15 @@ public DistanceMatrixApiRequest mode(TravelMode mode) {
|| TravelMode.TRANSIT.equals(mode)) {
return param("mode", mode);
}
throw new IllegalArgumentException("Distance Matrix API travel modes must be Driving, "
+ "Transit, Walking or Bicycling");
throw new IllegalArgumentException(
"Distance Matrix API travel modes must be Driving, " + "Transit, Walking or Bicycling");
}

/**
* Introduces restrictions to the route. Only one restriction can be specified.
*
* @param restriction One of {@link RouteRestriction#TOLLS}, {@link RouteRestriction#FERRIES} or
* {@link RouteRestriction#HIGHWAYS}.
* {@link RouteRestriction#HIGHWAYS}.
*/
public DistanceMatrixApiRequest avoid(RouteRestriction restriction) {
return param("avoid", restriction);
Expand All @@ -128,7 +124,7 @@ public DistanceMatrixApiRequest avoid(RouteRestriction restriction) {
*
* @param unit One of {@link Unit#METRIC}, {@link Unit#IMPERIAL}.
* @see <a href="https://developers.google.com/maps/documentation/distancematrix/#unit_systems">
* Unit systems in the Distance Matrix API</a>
* Unit systems in the Distance Matrix API</a>
*/
public DistanceMatrixApiRequest units(Unit unit) {
return param("units", unit);
Expand All @@ -137,12 +133,15 @@ public DistanceMatrixApiRequest units(Unit unit) {
/**
* Specifies the desired time of departure.
*
* <p>The departure time may be specified in two cases: <ul><li>For requests where the travel mode
* is transit: You can optionally specify one of departure_time or arrival_time. If neither time
* is specified, the departure_time defaults to now (that is, the departure time defaults to the
* current time).</li> <li>For requests where the travel mode is driving: Google Maps API for Work
* customers can specify the departure_time to receive trip duration considering current traffic
* conditions. The departure_time must be set to within a few minutes of the current time.</li>
* <p>The departure time may be specified in two cases:
*
* <ul>
* <li>For requests where the travel mode is transit: You can optionally specify one of
* departure_time or arrival_time. If neither time is specified, the departure_time defaults
* to now (that is, the departure time defaults to the current time).
* <li>For requests where the travel mode is driving: Google Maps API for Work customers can
* specify the departure_time to receive trip duration considering current traffic
* conditions. The departure_time must be set to within a few minutes of the current time.
* </ul>
*
* <p>Setting the parameter to null will remove it from the API request.
Expand All @@ -154,9 +153,8 @@ public DistanceMatrixApiRequest departureTime(ReadableInstant departureTime) {
}

/**
* Specifies the assumptions to use when calculating time in traffic. This
* parameter may only be specified when the travel mode is driving and
* the request includes a departure_time.
* Specifies the assumptions to use when calculating time in traffic. This parameter may only be
* specified when the travel mode is driving and the request includes a departure_time.
*/
public DistanceMatrixApiRequest trafficModel(TrafficModel trafficModel) {
return param("traffic_model", trafficModel);
Expand Down Expand Up @@ -185,4 +183,4 @@ public DistanceMatrixApiRequest transitModes(TransitMode... transitModes) {
public DistanceMatrixApiRequest transitRoutingPreference(TransitRoutingPreference pref) {
return param("transit_routing_preference", pref);
}
}
}
Loading

0 comments on commit 5b7d373

Please sign in to comment.