-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
53 changed files
with
1,191 additions
and
372 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
core/src/main/java/org/mobilitydata/gtfsvalidator/table/GtfsEntityContainer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package org.mobilitydata.gtfsvalidator.table; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
/** | ||
* This class is the parent of containers holding table (csv) entities and containers holding JSON | ||
* entities | ||
* | ||
* @param <T> The entity for this container (e.g. GtfsCalendarDate or GtfsGeojsonFeature ) | ||
* @param <D> The descriptor for the file for the container (e.g. GtfsCalendarDateTableDescriptor or | ||
* GtfsGeojsonFileDescriptor) | ||
*/ | ||
public abstract class GtfsEntityContainer<T extends GtfsEntity, D extends GtfsFileDescriptor> { | ||
|
||
private final D descriptor; | ||
private final TableStatus tableStatus; | ||
|
||
public GtfsEntityContainer(D descriptor, TableStatus tableStatus) { | ||
this.tableStatus = tableStatus; | ||
this.descriptor = descriptor; | ||
} | ||
|
||
public TableStatus getTableStatus() { | ||
return tableStatus; | ||
} | ||
|
||
public D getDescriptor() { | ||
return descriptor; | ||
} | ||
|
||
public abstract Class<T> getEntityClass(); | ||
|
||
public int entityCount() { | ||
return getEntities().size(); | ||
} | ||
|
||
public abstract List<T> getEntities(); | ||
|
||
public abstract String gtfsFilename(); | ||
|
||
public abstract Optional<T> byTranslationKey(String recordId, String recordSubId); | ||
|
||
public boolean isMissingFile() { | ||
return tableStatus == TableStatus.MISSING_FILE; | ||
} | ||
|
||
public boolean isParsedSuccessfully() { | ||
switch (tableStatus) { | ||
case PARSABLE_HEADERS_AND_ROWS: | ||
return true; | ||
case MISSING_FILE: | ||
return !descriptor.isRequired(); | ||
default: | ||
return false; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.