diff --git a/CHANGELOG.md b/CHANGELOG.md index a5575b7..349b229 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ -## 1.1.3 [unreleased] +## 1.1.4 [unreleased] * [fix] Fixed issue with direction ID as `String` instead if `Integer` (#2) +* [fix] Fixed issue with vehicle ID being `null` (#3) ## 1.1.3 [2018-11-13] * [security] Updates Jackson dependency 2.9.4 to 2.9.7 (CVE-2018-7489) diff --git a/src/main/java/de/stklcode/pubtrans/ura/model/Trip.java b/src/main/java/de/stklcode/pubtrans/ura/model/Trip.java index c7f0583..e61fe89 100644 --- a/src/main/java/de/stklcode/pubtrans/ura/model/Trip.java +++ b/src/main/java/de/stklcode/pubtrans/ura/model/Trip.java @@ -204,6 +204,8 @@ public final class Trip implements Model { || raw.get(VEHICLE_ID) instanceof Integer || raw.get(VEHICLE_ID) instanceof Long) { vehicleID = raw.get(VEHICLE_ID).toString(); + } else if (raw.get(VEHICLE_ID) == null) { // Only fail of field is not NULL (#3). + vehicleID = null; } else { throw Model.typeError(VEHICLE_ID, raw.get(VEHICLE_ID).getClass(), "String/Integer/Long"); } @@ -287,7 +289,7 @@ public final class Trip implements Model { } /** - * @return The vehicle ID. + * @return The vehicle ID or {@code null} if not present. */ public String getVehicleID() { return vehicleID; diff --git a/src/test/resources/de/stklcode/pubtrans/ura/instant_V1_trips_stop_name.txt b/src/test/resources/de/stklcode/pubtrans/ura/instant_V1_trips_stop_name.txt index 4192099..003a62d 100644 --- a/src/test/resources/de/stklcode/pubtrans/ura/instant_V1_trips_stop_name.txt +++ b/src/test/resources/de/stklcode/pubtrans/ura/instant_V1_trips_stop_name.txt @@ -8,4 +8,4 @@ [1,"Uniklinik","100600","H.3",0,50.7756388,6.04425,29,"10","3.B","1","Uniklinik-Ponttor-Hbf.","Uniklinik-Ponttor-Hbf.","347",92000053015001,1483363099000] [1,"Uniklinik","100600","H.1",0,50.7756388,6.04425,28,"3","3.A","1","Uniklinik-Schanz-Hbf.","Uniklinik-Schanz-Hbf.","325",92000288012001,1483363080000] [1,"Uniklinik","100600","H.2",0,50.7756388,6.04425,6,"70","70","1","Aachen Adenauerallee","Aachen Adenauerallee","588",92000225009001,1483363346000] -[1,"Uniklinik","100600","H.1",0,50.7756388,6.04425,1,"3","3.A","1","Schanz-Hbf.-Ponttor","Schanz-Hbf.-Ponttor","325",92000288013001,1483363380000] +[1,"Uniklinik","100600","H.1",0,50.7756388,6.04425,1,"3","3.A","1","Schanz-Hbf.-Ponttor","Schanz-Hbf.-Ponttor",null,92000288013001,1483363380000]