Model classes and input parameters declared final
As model classes are not designed for inheritance and about all method parameters are already effectively final, they have been explicitly declared final.
This commit is contained in:
@ -72,7 +72,7 @@ public class UraClient {
|
|||||||
*
|
*
|
||||||
* @param baseURL The base URL (with protocol, without trailing slash).
|
* @param baseURL The base URL (with protocol, without trailing slash).
|
||||||
*/
|
*/
|
||||||
public UraClient(String baseURL) {
|
public UraClient(final String baseURL) {
|
||||||
this(baseURL, DEFAULT_INSTANT_URL, DEFAULT_STREAM_URL);
|
this(baseURL, DEFAULT_INSTANT_URL, DEFAULT_STREAM_URL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,7 +83,7 @@ public class UraClient {
|
|||||||
* @param instantURL The path for instant requests.
|
* @param instantURL The path for instant requests.
|
||||||
* @param streamURL The path for stream requests.
|
* @param streamURL The path for stream requests.
|
||||||
*/
|
*/
|
||||||
public UraClient(String baseURL, String instantURL, String streamURL) {
|
public UraClient(final String baseURL, final String instantURL, final String streamURL) {
|
||||||
this.baseURL = baseURL;
|
this.baseURL = baseURL;
|
||||||
this.instantURL = instantURL;
|
this.instantURL = instantURL;
|
||||||
this.streamURL = streamURL;
|
this.streamURL = streamURL;
|
||||||
@ -96,7 +96,7 @@ public class UraClient {
|
|||||||
* @param stops Stop IDs
|
* @param stops Stop IDs
|
||||||
* @return the request
|
* @return the request
|
||||||
*/
|
*/
|
||||||
public Query forStops(final String... stops) {
|
public final Query forStops(final String... stops) {
|
||||||
return new Query().forStops(stops);
|
return new Query().forStops(stops);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,7 +106,7 @@ public class UraClient {
|
|||||||
* @param stopNames Stop Point Names
|
* @param stopNames Stop Point Names
|
||||||
* @return the request
|
* @return the request
|
||||||
*/
|
*/
|
||||||
public Query forStopsByName(final String... stopNames) {
|
public final Query forStopsByName(final String... stopNames) {
|
||||||
return new Query().forStopsByName(stopNames);
|
return new Query().forStopsByName(stopNames);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,7 +116,7 @@ public class UraClient {
|
|||||||
* @param lines Line IDs.
|
* @param lines Line IDs.
|
||||||
* @return The request.
|
* @return The request.
|
||||||
*/
|
*/
|
||||||
public Query forLines(final String... lines) {
|
public final Query forLines(final String... lines) {
|
||||||
return new Query().forLines(lines);
|
return new Query().forLines(lines);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,7 +126,7 @@ public class UraClient {
|
|||||||
* @param lineNames Line names.
|
* @param lineNames Line names.
|
||||||
* @return The request.
|
* @return The request.
|
||||||
*/
|
*/
|
||||||
public Query forLinesByName(final String... lineNames) {
|
public final Query forLinesByName(final String... lineNames) {
|
||||||
return new Query().forLinesByName(lineNames);
|
return new Query().forLinesByName(lineNames);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -136,7 +136,7 @@ public class UraClient {
|
|||||||
* @param direction The direction ID.
|
* @param direction The direction ID.
|
||||||
* @return The request.
|
* @return The request.
|
||||||
*/
|
*/
|
||||||
public Query forDirection(final Integer direction) {
|
public final Query forDirection(final Integer direction) {
|
||||||
return new Query().forDirection(direction);
|
return new Query().forDirection(direction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,7 +147,7 @@ public class UraClient {
|
|||||||
* @return The request.
|
* @return The request.
|
||||||
* @since 1.1.0
|
* @since 1.1.0
|
||||||
*/
|
*/
|
||||||
public Query forDestinationNames(final String... destinationNames) {
|
public final Query forDestinationNames(final String... destinationNames) {
|
||||||
return new Query().forDestinationNames(destinationNames);
|
return new Query().forDestinationNames(destinationNames);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -158,7 +158,7 @@ public class UraClient {
|
|||||||
* @return The request.
|
* @return The request.
|
||||||
* @since 1.1.0
|
* @since 1.1.0
|
||||||
*/
|
*/
|
||||||
public Query towards(final String... towards) {
|
public final Query towards(final String... towards) {
|
||||||
return new Query().towards(towards);
|
return new Query().towards(towards);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -171,7 +171,7 @@ public class UraClient {
|
|||||||
* @return The request.
|
* @return The request.
|
||||||
* @since 1.1.0
|
* @since 1.1.0
|
||||||
*/
|
*/
|
||||||
public Query forPosition(final Double latitude, final Double longitude, final Integer radius) {
|
public final Query forPosition(final Double latitude, final Double longitude, final Integer radius) {
|
||||||
return new Query().forPosition(latitude, longitude, radius);
|
return new Query().forPosition(latitude, longitude, radius);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -203,7 +203,7 @@ public class UraClient {
|
|||||||
* @param query The query.
|
* @param query The query.
|
||||||
* @return List of trips.
|
* @return List of trips.
|
||||||
*/
|
*/
|
||||||
public List<Trip> getTrips(Query query) {
|
public List<Trip> getTrips(final Query query) {
|
||||||
return getTrips(query, null);
|
return getTrips(query, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -254,7 +254,7 @@ public class UraClient {
|
|||||||
* @param query The query.
|
* @param query The query.
|
||||||
* @return The list.
|
* @return The list.
|
||||||
*/
|
*/
|
||||||
public List<Stop> getStops(Query query) {
|
public List<Stop> getStops(final Query query) {
|
||||||
List<Stop> stops = new ArrayList<>();
|
List<Stop> stops = new ArrayList<>();
|
||||||
try (InputStream is = requestInstant(REQUEST_STOP, query);
|
try (InputStream is = requestInstant(REQUEST_STOP, query);
|
||||||
BufferedReader br = new BufferedReader(new InputStreamReader(is))) {
|
BufferedReader br = new BufferedReader(new InputStreamReader(is))) {
|
||||||
@ -281,7 +281,7 @@ public class UraClient {
|
|||||||
* @return Input stream of the URL
|
* @return Input stream of the URL
|
||||||
* @throws IOException on errors
|
* @throws IOException on errors
|
||||||
*/
|
*/
|
||||||
private InputStream requestInstant(String[] returnList, Query query) throws IOException {
|
private InputStream requestInstant(final String[] returnList, final Query query) throws IOException {
|
||||||
String urlStr = baseURL + instantURL + "?ReturnList=" + String.join(",", returnList);
|
String urlStr = baseURL + instantURL + "?ReturnList=" + String.join(",", returnList);
|
||||||
|
|
||||||
if (query.stopIDs != null && query.stopIDs.length > 0) {
|
if (query.stopIDs != null && query.stopIDs.length > 0) {
|
||||||
@ -317,7 +317,7 @@ public class UraClient {
|
|||||||
/**
|
/**
|
||||||
* Request meta object.
|
* Request meta object.
|
||||||
*/
|
*/
|
||||||
public class Query {
|
public final class Query {
|
||||||
private String[] stopIDs;
|
private String[] stopIDs;
|
||||||
private String[] stopNames;
|
private String[] stopNames;
|
||||||
private String[] lineIDs;
|
private String[] lineIDs;
|
||||||
|
@ -24,7 +24,7 @@ import java.util.List;
|
|||||||
*
|
*
|
||||||
* @author Stefan Kalscheuer
|
* @author Stefan Kalscheuer
|
||||||
*/
|
*/
|
||||||
public class Stop {
|
public final class Stop {
|
||||||
private static final int STOP_NAME = 1;
|
private static final int STOP_NAME = 1;
|
||||||
private static final int STOP_ID = 2;
|
private static final int STOP_ID = 2;
|
||||||
private static final int INDICATOR = 3;
|
private static final int INDICATOR = 3;
|
||||||
@ -50,7 +50,12 @@ public class Stop {
|
|||||||
* @param latitude Stop geolocation latitude.
|
* @param latitude Stop geolocation latitude.
|
||||||
* @param longitude Stop geolocation longitude.
|
* @param longitude Stop geolocation longitude.
|
||||||
*/
|
*/
|
||||||
public Stop(String id, String name, String indicator, Integer state, Double latitude, Double longitude) {
|
public Stop(final String id,
|
||||||
|
final String name,
|
||||||
|
final String indicator,
|
||||||
|
final Integer state,
|
||||||
|
final Double latitude,
|
||||||
|
final Double longitude) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.indicator = indicator;
|
this.indicator = indicator;
|
||||||
@ -65,7 +70,7 @@ public class Stop {
|
|||||||
* @param raw List of attributes from JSON line
|
* @param raw List of attributes from JSON line
|
||||||
* @throws IOException Thrown on invalid line format.
|
* @throws IOException Thrown on invalid line format.
|
||||||
*/
|
*/
|
||||||
public Stop(List raw) throws IOException {
|
public Stop(final List raw) throws IOException {
|
||||||
if (raw == null || raw.size() < NUM_OF_FIELDS) {
|
if (raw == null || raw.size() < NUM_OF_FIELDS) {
|
||||||
throw new IOException("Invalid number of fields");
|
throw new IOException("Invalid number of fields");
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ import java.util.List;
|
|||||||
*
|
*
|
||||||
* @author Stefan Kalscheuer
|
* @author Stefan Kalscheuer
|
||||||
*/
|
*/
|
||||||
public class Trip {
|
public final class Trip {
|
||||||
private static final int VISIT_ID = 7;
|
private static final int VISIT_ID = 7;
|
||||||
private static final int LINE_ID = 8;
|
private static final int LINE_ID = 8;
|
||||||
private static final int LINE_NAME = 9;
|
private static final int LINE_NAME = 9;
|
||||||
@ -66,21 +66,21 @@ public class Trip {
|
|||||||
* @param tripID Trip ID.
|
* @param tripID Trip ID.
|
||||||
* @param estimatedTime Estimated time.
|
* @param estimatedTime Estimated time.
|
||||||
*/
|
*/
|
||||||
public Trip(String stopID,
|
public Trip(final String stopID,
|
||||||
String stopName,
|
final String stopName,
|
||||||
String stopIndicator,
|
final String stopIndicator,
|
||||||
Integer stopState,
|
final Integer stopState,
|
||||||
Double stopLatitude,
|
final Double stopLatitude,
|
||||||
Double stopLongitude,
|
final Double stopLongitude,
|
||||||
Integer visitID,
|
final Integer visitID,
|
||||||
String lineID,
|
final String lineID,
|
||||||
String lineName,
|
final String lineName,
|
||||||
Integer directionID,
|
final Integer directionID,
|
||||||
String destinationName,
|
final String destinationName,
|
||||||
String destinationText,
|
final String destinationText,
|
||||||
String vehicleID,
|
final String vehicleID,
|
||||||
String tripID,
|
final String tripID,
|
||||||
Long estimatedTime) {
|
final Long estimatedTime) {
|
||||||
this(new Stop(stopID,
|
this(new Stop(stopID,
|
||||||
stopName,
|
stopName,
|
||||||
stopIndicator,
|
stopIndicator,
|
||||||
@ -112,16 +112,16 @@ public class Trip {
|
|||||||
* @param tripID Trip ID
|
* @param tripID Trip ID
|
||||||
* @param estimatedTime Estimated time
|
* @param estimatedTime Estimated time
|
||||||
*/
|
*/
|
||||||
public Trip(Stop stop,
|
public Trip(final Stop stop,
|
||||||
Integer visitID,
|
final Integer visitID,
|
||||||
String lineID,
|
final String lineID,
|
||||||
String lineName,
|
final String lineName,
|
||||||
Integer directionID,
|
final Integer directionID,
|
||||||
String destinationName,
|
final String destinationName,
|
||||||
String destinationText,
|
final String destinationText,
|
||||||
String vehicleID,
|
final String vehicleID,
|
||||||
String tripID,
|
final String tripID,
|
||||||
Long estimatedTime) {
|
final Long estimatedTime) {
|
||||||
this.stop = stop;
|
this.stop = stop;
|
||||||
this.visitID = visitID;
|
this.visitID = visitID;
|
||||||
this.lineID = lineID;
|
this.lineID = lineID;
|
||||||
@ -140,7 +140,7 @@ public class Trip {
|
|||||||
* @param raw List of attributes from JSON line
|
* @param raw List of attributes from JSON line
|
||||||
* @throws IOException Thrown on invalid line format.
|
* @throws IOException Thrown on invalid line format.
|
||||||
*/
|
*/
|
||||||
public Trip(List raw) throws IOException {
|
public Trip(final List raw) throws IOException {
|
||||||
this(raw, null);
|
this(raw, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,7 +151,7 @@ public class Trip {
|
|||||||
* @param version API version
|
* @param version API version
|
||||||
* @throws IOException Thrown on invalid line format.
|
* @throws IOException Thrown on invalid line format.
|
||||||
*/
|
*/
|
||||||
public Trip(List raw, String version) throws IOException {
|
public Trip(final List raw, final String version) throws IOException {
|
||||||
if (raw == null || raw.size() < NUM_OF_FIELDS) {
|
if (raw == null || raw.size() < NUM_OF_FIELDS) {
|
||||||
throw new IOException("Invalid number of fields");
|
throw new IOException("Invalid number of fields");
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user