Skip to content

Commit 35bf825

Browse files
authored
Move GTFS field names from table loader to entity classes (#1274)
E.g., use GtfsStop.STOP_ID_FIELD_NAME instead of GtfsStopTableLoader.STOP_ID_FIELD_NAME. Motivation 1. Table loader classes should be only used for loading data tables. They should not be used by validator classes. 2. Our final goal is to stop generating table loader classes and instead have a manually written classe that uses GTFS schema as a parameter. GTFS field names have to be generated, so we move them to entity classes that are generated anyway.
1 parent 8416316 commit 35bf825

18 files changed

+132
-145
lines changed

main/src/main/java/org/mobilitydata/gtfsvalidator/validator/AgencyConsistencyValidator.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import org.mobilitydata.gtfsvalidator.notice.ValidationNotice;
2727
import org.mobilitydata.gtfsvalidator.table.GtfsAgency;
2828
import org.mobilitydata.gtfsvalidator.table.GtfsAgencyTableContainer;
29-
import org.mobilitydata.gtfsvalidator.table.GtfsAgencyTableLoader;
3029

3130
/**
3231
* Validates that all agencies have the same timezone and language and that agency_id field is set
@@ -63,7 +62,7 @@ public void validate(NoticeContainer noticeContainer) {
6362
new MissingRequiredFieldNotice(
6463
agencyTable.gtfsFilename(),
6564
agency.csvRowNumber(),
66-
GtfsAgencyTableLoader.AGENCY_ID_FIELD_NAME));
65+
GtfsAgency.AGENCY_ID_FIELD_NAME));
6766
}
6867
}
6968

main/src/main/java/org/mobilitydata/gtfsvalidator/validator/GtfsTripServiceIdForeignKeyValidator.java

+6-7
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,12 @@
2020
import org.mobilitydata.gtfsvalidator.annotation.GtfsValidator;
2121
import org.mobilitydata.gtfsvalidator.notice.ForeignKeyViolationNotice;
2222
import org.mobilitydata.gtfsvalidator.notice.NoticeContainer;
23+
import org.mobilitydata.gtfsvalidator.table.GtfsCalendar;
24+
import org.mobilitydata.gtfsvalidator.table.GtfsCalendarDate;
2325
import org.mobilitydata.gtfsvalidator.table.GtfsCalendarDateTableContainer;
24-
import org.mobilitydata.gtfsvalidator.table.GtfsCalendarDateTableLoader;
2526
import org.mobilitydata.gtfsvalidator.table.GtfsCalendarTableContainer;
26-
import org.mobilitydata.gtfsvalidator.table.GtfsCalendarTableLoader;
2727
import org.mobilitydata.gtfsvalidator.table.GtfsTrip;
2828
import org.mobilitydata.gtfsvalidator.table.GtfsTripTableContainer;
29-
import org.mobilitydata.gtfsvalidator.table.GtfsTripTableLoader;
3029

3130
/**
3231
* Validates that service_id field in "trips.txt" references a valid service_id in "calendar.txt" or
@@ -57,10 +56,10 @@ public void validate(NoticeContainer noticeContainer) {
5756
if (!hasReferencedKey(childKey, calendarContainer, calendarDateContainer)) {
5857
noticeContainer.addValidationNotice(
5958
new ForeignKeyViolationNotice(
60-
GtfsTripTableLoader.FILENAME,
61-
GtfsTripTableLoader.SERVICE_ID_FIELD_NAME,
62-
GtfsCalendarTableLoader.FILENAME + " or " + GtfsCalendarDateTableLoader.FILENAME,
63-
GtfsCalendarTableLoader.SERVICE_ID_FIELD_NAME,
59+
GtfsTrip.FILENAME,
60+
GtfsTrip.SERVICE_ID_FIELD_NAME,
61+
GtfsCalendar.FILENAME + " or " + GtfsCalendarDate.FILENAME,
62+
GtfsCalendar.SERVICE_ID_FIELD_NAME,
6463
childKey,
6564
trip.csvRowNumber()));
6665
}

main/src/main/java/org/mobilitydata/gtfsvalidator/validator/MissingTripEdgeValidator.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616

1717
package org.mobilitydata.gtfsvalidator.validator;
1818

19-
import static org.mobilitydata.gtfsvalidator.table.GtfsStopTimeTableLoader.ARRIVAL_TIME_FIELD_NAME;
20-
import static org.mobilitydata.gtfsvalidator.table.GtfsStopTimeTableLoader.DEPARTURE_TIME_FIELD_NAME;
19+
import static org.mobilitydata.gtfsvalidator.table.GtfsStopTime.ARRIVAL_TIME_FIELD_NAME;
20+
import static org.mobilitydata.gtfsvalidator.table.GtfsStopTime.DEPARTURE_TIME_FIELD_NAME;
2121

2222
import com.google.common.collect.Multimaps;
2323
import java.util.List;

main/src/main/java/org/mobilitydata/gtfsvalidator/validator/PathwayEndpointTypeValidator.java

+2-9
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import org.mobilitydata.gtfsvalidator.notice.ValidationNotice;
2525
import org.mobilitydata.gtfsvalidator.table.GtfsPathway;
2626
import org.mobilitydata.gtfsvalidator.table.GtfsPathwayTableContainer;
27-
import org.mobilitydata.gtfsvalidator.table.GtfsPathwayTableLoader;
2827
import org.mobilitydata.gtfsvalidator.table.GtfsStop;
2928
import org.mobilitydata.gtfsvalidator.table.GtfsStopTableContainer;
3029

@@ -54,15 +53,9 @@ public class PathwayEndpointTypeValidator extends FileValidator {
5453
public void validate(NoticeContainer noticeContainer) {
5554
for (GtfsPathway pathway : pathwayTable.getEntities()) {
5655
checkEndpoint(
57-
pathway,
58-
GtfsPathwayTableLoader.FROM_STOP_ID_FIELD_NAME,
59-
pathway.fromStopId(),
60-
noticeContainer);
56+
pathway, GtfsPathway.FROM_STOP_ID_FIELD_NAME, pathway.fromStopId(), noticeContainer);
6157
checkEndpoint(
62-
pathway,
63-
GtfsPathwayTableLoader.TO_STOP_ID_FIELD_NAME,
64-
pathway.toStopId(),
65-
noticeContainer);
58+
pathway, GtfsPathway.TO_STOP_ID_FIELD_NAME, pathway.toStopId(), noticeContainer);
6659
}
6760
}
6861

main/src/main/java/org/mobilitydata/gtfsvalidator/validator/StopTimeArrivalAndDepartureTimeValidator.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import org.mobilitydata.gtfsvalidator.notice.ValidationNotice;
2626
import org.mobilitydata.gtfsvalidator.table.GtfsStopTime;
2727
import org.mobilitydata.gtfsvalidator.table.GtfsStopTimeTableContainer;
28-
import org.mobilitydata.gtfsvalidator.table.GtfsStopTimeTableLoader;
2928
import org.mobilitydata.gtfsvalidator.type.GtfsTime;
3029

3130
/**
@@ -64,8 +63,8 @@ public void validate(NoticeContainer noticeContainer) {
6463
stopTime.tripId(),
6564
stopTime.stopSequence(),
6665
hasArrival
67-
? GtfsStopTimeTableLoader.ARRIVAL_TIME_FIELD_NAME
68-
: GtfsStopTimeTableLoader.DEPARTURE_TIME_FIELD_NAME));
66+
? GtfsStopTime.ARRIVAL_TIME_FIELD_NAME
67+
: GtfsStopTime.DEPARTURE_TIME_FIELD_NAME));
6968
}
7069
if (hasArrival
7170
&& previousDepartureRow != -1

main/src/main/java/org/mobilitydata/gtfsvalidator/validator/TimepointTimeValidator.java

+4-5
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import org.mobilitydata.gtfsvalidator.notice.ValidationNotice;
2424
import org.mobilitydata.gtfsvalidator.table.GtfsStopTime;
2525
import org.mobilitydata.gtfsvalidator.table.GtfsStopTimeTableContainer;
26-
import org.mobilitydata.gtfsvalidator.table.GtfsStopTimeTableLoader;
2726
import org.mobilitydata.gtfsvalidator.table.GtfsStopTimeTimepoint;
2827

2928
/**
@@ -49,7 +48,7 @@ public class TimepointTimeValidator extends FileValidator {
4948

5049
@Override
5150
public void validate(NoticeContainer noticeContainer) {
52-
if (!stopTimes.hasColumn(GtfsStopTimeTableLoader.TIMEPOINT_FIELD_NAME)) {
51+
if (!stopTimes.hasColumn(GtfsStopTime.TIMEPOINT_FIELD_NAME)) {
5352
// legacy datasets do not use timepoint column in stop_times.txt as a result:
5453
// - this should be flagged;
5554
// - but also no notice regarding the absence of arrival_time or departure_time should be
@@ -65,12 +64,12 @@ public void validate(NoticeContainer noticeContainer) {
6564
if (!stopTime.hasArrivalTime()) {
6665
noticeContainer.addValidationNotice(
6766
new StopTimeTimepointWithoutTimesNotice(
68-
stopTime, GtfsStopTimeTableLoader.ARRIVAL_TIME_FIELD_NAME));
67+
stopTime, GtfsStopTime.ARRIVAL_TIME_FIELD_NAME));
6968
}
7069
if (!stopTime.hasDepartureTime()) {
7170
noticeContainer.addValidationNotice(
7271
new StopTimeTimepointWithoutTimesNotice(
73-
stopTime, GtfsStopTimeTableLoader.DEPARTURE_TIME_FIELD_NAME));
72+
stopTime, GtfsStopTime.DEPARTURE_TIME_FIELD_NAME));
7473
}
7574
}
7675
}
@@ -128,7 +127,7 @@ static class MissingTimepointColumnNotice extends ValidationNotice {
128127

129128
MissingTimepointColumnNotice() {
130129
super(SeverityLevel.WARNING);
131-
this.filename = GtfsStopTimeTableLoader.FILENAME;
130+
this.filename = GtfsStopTime.FILENAME;
132131
}
133132
}
134133
}

main/src/main/java/org/mobilitydata/gtfsvalidator/validator/TransferDirection.java

+3-10
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package org.mobilitydata.gtfsvalidator.validator;
22

33
import org.mobilitydata.gtfsvalidator.table.GtfsTransfer;
4-
import org.mobilitydata.gtfsvalidator.table.GtfsTransferTableLoader;
54

65
/**
76
* An enum type, along with various convenience methods, for identifying the direction of transfer
@@ -20,9 +19,7 @@ public enum TransferDirection {
2019
TRANSFER_TO;
2120

2221
public String stopIdFieldName() {
23-
return isFrom()
24-
? GtfsTransferTableLoader.FROM_STOP_ID_FIELD_NAME
25-
: GtfsTransferTableLoader.TO_STOP_ID_FIELD_NAME;
22+
return isFrom() ? GtfsTransfer.FROM_STOP_ID_FIELD_NAME : GtfsTransfer.TO_STOP_ID_FIELD_NAME;
2623
}
2724

2825
public String stopId(GtfsTransfer transfer) {
@@ -34,9 +31,7 @@ public boolean hasStopId(GtfsTransfer transfer) {
3431
}
3532

3633
public String routeIdFieldName() {
37-
return isFrom()
38-
? GtfsTransferTableLoader.FROM_ROUTE_ID_FIELD_NAME
39-
: GtfsTransferTableLoader.TO_ROUTE_ID_FIELD_NAME;
34+
return isFrom() ? GtfsTransfer.FROM_ROUTE_ID_FIELD_NAME : GtfsTransfer.TO_ROUTE_ID_FIELD_NAME;
4035
}
4136

4237
public boolean hasRouteId(GtfsTransfer transfer) {
@@ -48,9 +43,7 @@ public String routeId(GtfsTransfer transfer) {
4843
}
4944

5045
public String tripIdFieldName() {
51-
return isFrom()
52-
? GtfsTransferTableLoader.FROM_TRIP_ID_FIELD_NAME
53-
: GtfsTransferTableLoader.TO_TRIP_ID_FIELD_NAME;
46+
return isFrom() ? GtfsTransfer.FROM_TRIP_ID_FIELD_NAME : GtfsTransfer.TO_TRIP_ID_FIELD_NAME;
5447
}
5548

5649
public boolean hasTripId(GtfsTransfer transfer) {

main/src/main/java/org/mobilitydata/gtfsvalidator/validator/TransfersInSeatTransferTypeValidator.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import org.mobilitydata.gtfsvalidator.table.GtfsStopTimeTableContainer;
1818
import org.mobilitydata.gtfsvalidator.table.GtfsTransfer;
1919
import org.mobilitydata.gtfsvalidator.table.GtfsTransferTableContainer;
20-
import org.mobilitydata.gtfsvalidator.table.GtfsTransferTableLoader;
2120
import org.mobilitydata.gtfsvalidator.table.GtfsTransferType;
2221
import org.mobilitydata.gtfsvalidator.validator.TransfersStopTypeValidator.TransferWithInvalidStopLocationTypeNotice;
2322

@@ -65,7 +64,7 @@ public void validateEntity(GtfsTransfer transfer, NoticeContainer noticeContaine
6564
if (!transferDirection.hasTripId(transfer)) {
6665
noticeContainer.addValidationNotice(
6766
new MissingRequiredFieldNotice(
68-
GtfsTransferTableLoader.FILENAME,
67+
GtfsTransfer.FILENAME,
6968
transfer.csvRowNumber(),
7069
transferDirection.tripIdFieldName()));
7170
}

main/src/main/java/org/mobilitydata/gtfsvalidator/validator/TranslationFieldAndReferenceValidator.java

+12-17
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import org.mobilitydata.gtfsvalidator.table.GtfsTableContainer;
2929
import org.mobilitydata.gtfsvalidator.table.GtfsTranslation;
3030
import org.mobilitydata.gtfsvalidator.table.GtfsTranslationTableContainer;
31-
import org.mobilitydata.gtfsvalidator.table.GtfsTranslationTableLoader;
3231

3332
/**
3433
* Validates that translations are provided in accordance with GTFS Specification.
@@ -54,7 +53,7 @@ public class TranslationFieldAndReferenceValidator extends FileValidator {
5453
@Override
5554
public void validate(NoticeContainer noticeContainer) {
5655
// The legacy Google translation format does not define `translations.table_name` field.
57-
if (!translationTable.getHeader().hasColumn(GtfsTranslationTableLoader.TABLE_NAME_FIELD_NAME)) {
56+
if (!translationTable.getHeader().hasColumn(GtfsTranslation.TABLE_NAME_FIELD_NAME)) {
5857
// Skip validation if legacy Google translation format is detected.
5958
return;
6059
}
@@ -81,25 +80,25 @@ private boolean validateStandardRequiredFields(NoticeContainer noticeContainer)
8180
if (!translation.hasFieldName()) {
8281
noticeContainer.addValidationNotice(
8382
new MissingRequiredFieldNotice(
84-
GtfsTranslationTableLoader.FILENAME,
83+
GtfsTranslation.FILENAME,
8584
translation.csvRowNumber(),
86-
GtfsTranslationTableLoader.FIELD_NAME_FIELD_NAME));
85+
GtfsTranslation.FIELD_NAME_FIELD_NAME));
8786
isValid = false;
8887
}
8988
if (!translation.hasLanguage()) {
9089
noticeContainer.addValidationNotice(
9190
new MissingRequiredFieldNotice(
92-
GtfsTranslationTableLoader.FILENAME,
91+
GtfsTranslation.FILENAME,
9392
translation.csvRowNumber(),
94-
GtfsTranslationTableLoader.LANGUAGE_FIELD_NAME));
93+
GtfsTranslation.LANGUAGE_FIELD_NAME));
9594
isValid = false;
9695
}
9796
if (!translation.hasTableName()) {
9897
noticeContainer.addValidationNotice(
9998
new MissingRequiredFieldNotice(
100-
GtfsTranslationTableLoader.FILENAME,
99+
GtfsTranslation.FILENAME,
101100
translation.csvRowNumber(),
102-
GtfsTranslationTableLoader.TABLE_NAME_FIELD_NAME));
101+
GtfsTranslation.TABLE_NAME_FIELD_NAME));
103102
isValid = false;
104103
}
105104
}
@@ -112,16 +111,12 @@ private void validateTranslation(GtfsTranslation translation, NoticeContainer no
112111
if (translation.hasRecordId()) {
113112
noticeContainer.addValidationNotice(
114113
new TranslationUnexpectedValueNotice(
115-
translation,
116-
GtfsTranslationTableLoader.RECORD_ID_FIELD_NAME,
117-
translation.recordId()));
114+
translation, GtfsTranslation.RECORD_ID_FIELD_NAME, translation.recordId()));
118115
}
119116
if (translation.hasRecordSubId()) {
120117
noticeContainer.addValidationNotice(
121118
new TranslationUnexpectedValueNotice(
122-
translation,
123-
GtfsTranslationTableLoader.RECORD_SUB_ID_FIELD_NAME,
124-
translation.recordSubId()));
119+
translation, GtfsTranslation.RECORD_SUB_ID_FIELD_NAME, translation.recordSubId()));
125120
}
126121
}
127122
Optional<GtfsTableContainer<?>> parentTable =
@@ -146,14 +141,14 @@ private void validateReferenceIntegrity(
146141
translation,
147142
translation.hasRecordId(),
148143
keyColumnNames.size() >= 1,
149-
GtfsTranslationTableLoader.RECORD_ID_FIELD_NAME,
144+
GtfsTranslation.RECORD_ID_FIELD_NAME,
150145
translation.recordId(),
151146
noticeContainer)
152147
|| isMissingOrUnexpectedField(
153148
translation,
154149
translation.hasRecordSubId(),
155150
keyColumnNames.size() >= 2,
156-
GtfsTranslationTableLoader.RECORD_SUB_ID_FIELD_NAME,
151+
GtfsTranslation.RECORD_SUB_ID_FIELD_NAME,
157152
translation.recordSubId(),
158153
noticeContainer)) {
159154
return;
@@ -187,7 +182,7 @@ private static boolean isMissingOrUnexpectedField(
187182
} else {
188183
noticeContainer.addValidationNotice(
189184
new MissingRequiredFieldNotice(
190-
GtfsTranslationTableLoader.FILENAME, translation.csvRowNumber(), fieldName));
185+
GtfsTranslation.FILENAME, translation.csvRowNumber(), fieldName));
191186
}
192187
return true;
193188
}

main/src/main/java/org/mobilitydata/gtfsvalidator/validator/TripAgencyIdValidator.java

+1-4
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import org.mobilitydata.gtfsvalidator.table.GtfsAgencyTableContainer;
2424
import org.mobilitydata.gtfsvalidator.table.GtfsRoute;
2525
import org.mobilitydata.gtfsvalidator.table.GtfsRouteTableContainer;
26-
import org.mobilitydata.gtfsvalidator.table.GtfsRouteTableLoader;
2726

2827
/**
2928
* Checks that agency_id field in "routes.txt" is defined for every row if there is more than 1
@@ -52,9 +51,7 @@ public void validate(NoticeContainer noticeContainer) {
5251
if (!route.hasAgencyId()) {
5352
noticeContainer.addValidationNotice(
5453
new MissingRequiredFieldNotice(
55-
routeTable.gtfsFilename(),
56-
route.csvRowNumber(),
57-
GtfsRouteTableLoader.AGENCY_ID_FIELD_NAME));
54+
routeTable.gtfsFilename(), route.csvRowNumber(), GtfsRoute.AGENCY_ID_FIELD_NAME));
5855
}
5956
// No need to check reference integrity because it is done by a validator generated from
6057
// @ForeignKey annotation.

main/src/test/java/org/mobilitydata/gtfsvalidator/validator/TimepointTimeValidatorTest.java

+12-12
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,18 @@
1717
package org.mobilitydata.gtfsvalidator.validator;
1818

1919
import static com.google.common.truth.Truth.assertThat;
20-
import static org.mobilitydata.gtfsvalidator.table.GtfsStopTableLoader.STOP_ID_FIELD_NAME;
21-
import static org.mobilitydata.gtfsvalidator.table.GtfsStopTimeTableLoader.ARRIVAL_TIME_FIELD_NAME;
22-
import static org.mobilitydata.gtfsvalidator.table.GtfsStopTimeTableLoader.CONTINUOUS_DROP_OFF_FIELD_NAME;
23-
import static org.mobilitydata.gtfsvalidator.table.GtfsStopTimeTableLoader.CONTINUOUS_PICKUP_FIELD_NAME;
24-
import static org.mobilitydata.gtfsvalidator.table.GtfsStopTimeTableLoader.DEPARTURE_TIME_FIELD_NAME;
25-
import static org.mobilitydata.gtfsvalidator.table.GtfsStopTimeTableLoader.DROP_OFF_TYPE_FIELD_NAME;
26-
import static org.mobilitydata.gtfsvalidator.table.GtfsStopTimeTableLoader.PICKUP_TYPE_FIELD_NAME;
27-
import static org.mobilitydata.gtfsvalidator.table.GtfsStopTimeTableLoader.SHAPE_DIST_TRAVELED_FIELD_NAME;
28-
import static org.mobilitydata.gtfsvalidator.table.GtfsStopTimeTableLoader.STOP_HEADSIGN_FIELD_NAME;
29-
import static org.mobilitydata.gtfsvalidator.table.GtfsStopTimeTableLoader.STOP_SEQUENCE_FIELD_NAME;
30-
import static org.mobilitydata.gtfsvalidator.table.GtfsStopTimeTableLoader.TIMEPOINT_FIELD_NAME;
31-
import static org.mobilitydata.gtfsvalidator.table.GtfsStopTimeTableLoader.TRIP_ID_FIELD_NAME;
20+
import static org.mobilitydata.gtfsvalidator.table.GtfsStop.STOP_ID_FIELD_NAME;
21+
import static org.mobilitydata.gtfsvalidator.table.GtfsStopTime.ARRIVAL_TIME_FIELD_NAME;
22+
import static org.mobilitydata.gtfsvalidator.table.GtfsStopTime.CONTINUOUS_DROP_OFF_FIELD_NAME;
23+
import static org.mobilitydata.gtfsvalidator.table.GtfsStopTime.CONTINUOUS_PICKUP_FIELD_NAME;
24+
import static org.mobilitydata.gtfsvalidator.table.GtfsStopTime.DEPARTURE_TIME_FIELD_NAME;
25+
import static org.mobilitydata.gtfsvalidator.table.GtfsStopTime.DROP_OFF_TYPE_FIELD_NAME;
26+
import static org.mobilitydata.gtfsvalidator.table.GtfsStopTime.PICKUP_TYPE_FIELD_NAME;
27+
import static org.mobilitydata.gtfsvalidator.table.GtfsStopTime.SHAPE_DIST_TRAVELED_FIELD_NAME;
28+
import static org.mobilitydata.gtfsvalidator.table.GtfsStopTime.STOP_HEADSIGN_FIELD_NAME;
29+
import static org.mobilitydata.gtfsvalidator.table.GtfsStopTime.STOP_SEQUENCE_FIELD_NAME;
30+
import static org.mobilitydata.gtfsvalidator.table.GtfsStopTime.TIMEPOINT_FIELD_NAME;
31+
import static org.mobilitydata.gtfsvalidator.table.GtfsStopTime.TRIP_ID_FIELD_NAME;
3232

3333
import java.util.ArrayList;
3434
import java.util.List;

processor/src/main/java/org/mobilitydata/gtfsvalidator/processor/CurrencyAmountValidatorGenerator.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ private static JavaFile generateValidator(GtfsFileDescriptor fileDescriptor) {
9696
.addStatement("$T currency = entity.$L()", Currency.class, currencyField.name())
9797
.beginControlFlow("if (amount.scale() != currency.getDefaultFractionDigits())")
9898
.addStatement(
99-
"noticeContainer.addValidationNotice(new $T(\"$L\", \"$L\", entity.csvRowNumber(), amount))",
99+
"noticeContainer.addValidationNotice(new $T(\"$L\", \"$L\", entity.csvRowNumber(),"
100+
+ " amount))",
100101
InvalidCurrencyAmountNotice.class,
101102
fileDescriptor.filename(),
102103
amountField.name())

processor/src/main/java/org/mobilitydata/gtfsvalidator/processor/EndRangeValidatorGenerator.java

+5-4
Original file line numberDiff line numberDiff line change
@@ -144,19 +144,20 @@ private static CodeBlock generateNoticeContext(
144144
GtfsFieldDescriptor startField,
145145
GtfsFieldDescriptor endField,
146146
StartEndRangeNoticeType noticeType) {
147-
TypeName tableLoaderTypeName = new GtfsEntityClasses(fileDescriptor).tableLoaderTypeName();
147+
TypeName gtfsEntityTypeName =
148+
new GtfsEntityClasses(fileDescriptor).entityImplementationTypeName();
148149
CodeBlock.Builder block =
149-
CodeBlock.builder().add("$T.FILENAME, entity.csvRowNumber(), ", tableLoaderTypeName);
150+
CodeBlock.builder().add("$T.FILENAME, entity.csvRowNumber(), ", gtfsEntityTypeName);
150151
if (fileDescriptor.hasSingleColumnPrimaryKey()) {
151152
block.add("entity.$L(), ", fileDescriptor.getSingleColumnPrimaryKey().name());
152153
}
153-
block.add("$T.$L, ", tableLoaderTypeName, FieldNameConverter.fieldNameField(startField.name()));
154+
block.add("$T.$L, ", gtfsEntityTypeName, FieldNameConverter.fieldNameField(startField.name()));
154155
if (noticeType.equals(StartEndRangeNoticeType.OUT_OF_ORDER)) {
155156
block.add("entity.$L().toString(), ", startField.name());
156157
}
157158
block.add(
158159
"$T.$L, entity.$L().toString()",
159-
tableLoaderTypeName,
160+
gtfsEntityTypeName,
160161
FieldNameConverter.fieldNameField(endField.name()),
161162
endField.name());
162163
return block.build();

0 commit comments

Comments
 (0)