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:
2017-08-04 10:12:12 +02:00
parent 1f4bd9f411
commit a8fc93fb41
3 changed files with 50 additions and 45 deletions

View File

@@ -24,7 +24,7 @@ import java.util.List;
*
* @author Stefan Kalscheuer
*/
public class Stop {
public final class Stop {
private static final int STOP_NAME = 1;
private static final int STOP_ID = 2;
private static final int INDICATOR = 3;
@@ -50,7 +50,12 @@ public class Stop {
* @param latitude Stop geolocation latitude.
* @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.name = name;
this.indicator = indicator;
@@ -65,7 +70,7 @@ public class Stop {
* @param raw List of attributes from JSON line
* @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) {
throw new IOException("Invalid number of fields");
}

View File

@@ -24,7 +24,7 @@ import java.util.List;
*
* @author Stefan Kalscheuer
*/
public class Trip {
public final class Trip {
private static final int VISIT_ID = 7;
private static final int LINE_ID = 8;
private static final int LINE_NAME = 9;
@@ -66,21 +66,21 @@ public class Trip {
* @param tripID Trip ID.
* @param estimatedTime Estimated time.
*/
public Trip(String stopID,
String stopName,
String stopIndicator,
Integer stopState,
Double stopLatitude,
Double stopLongitude,
Integer visitID,
String lineID,
String lineName,
Integer directionID,
String destinationName,
String destinationText,
String vehicleID,
String tripID,
Long estimatedTime) {
public Trip(final String stopID,
final String stopName,
final String stopIndicator,
final Integer stopState,
final Double stopLatitude,
final Double stopLongitude,
final Integer visitID,
final String lineID,
final String lineName,
final Integer directionID,
final String destinationName,
final String destinationText,
final String vehicleID,
final String tripID,
final Long estimatedTime) {
this(new Stop(stopID,
stopName,
stopIndicator,
@@ -112,16 +112,16 @@ public class Trip {
* @param tripID Trip ID
* @param estimatedTime Estimated time
*/
public Trip(Stop stop,
Integer visitID,
String lineID,
String lineName,
Integer directionID,
String destinationName,
String destinationText,
String vehicleID,
String tripID,
Long estimatedTime) {
public Trip(final Stop stop,
final Integer visitID,
final String lineID,
final String lineName,
final Integer directionID,
final String destinationName,
final String destinationText,
final String vehicleID,
final String tripID,
final Long estimatedTime) {
this.stop = stop;
this.visitID = visitID;
this.lineID = lineID;
@@ -140,7 +140,7 @@ public class Trip {
* @param raw List of attributes from JSON line
* @throws IOException Thrown on invalid line format.
*/
public Trip(List raw) throws IOException {
public Trip(final List raw) throws IOException {
this(raw, null);
}
@@ -151,7 +151,7 @@ public class Trip {
* @param version API version
* @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) {
throw new IOException("Invalid number of fields");
}