-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #574 from entur/use_enum_for_validation_profile
Use Java Enum for validation profile
- Loading branch information
Showing
6 changed files
with
110 additions
and
71 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
62 changes: 62 additions & 0 deletions
62
src/main/java/no/entur/antu/validation/ValidationProfile.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,62 @@ | ||
package no.entur.antu.validation; | ||
|
||
import java.util.EnumSet; | ||
import java.util.Objects; | ||
import java.util.Optional; | ||
|
||
/** | ||
* A validation profile is a collection of validation rules customized for a specific validation | ||
* use case. | ||
*/ | ||
public enum ValidationProfile { | ||
/** | ||
* Default profile for timetable data. | ||
*/ | ||
TIMETABLE("Timetable"), | ||
|
||
/** | ||
* Profile for flexible lines created in NPlan. | ||
*/ | ||
TIMETABLE_FLEXIBLE_TRANSPORT("TimetableFlexibleTransport"), | ||
|
||
/** | ||
* Profile for flexible lines imported through the operator portal. | ||
*/ | ||
IMPORT_TIMETABLE_FLEXIBLE_TRANSPORT("ImportTimetableFlexibleTransport"), | ||
|
||
/** | ||
* Profile for validating a dataset that contains both static data and flex data. | ||
*/ | ||
TIMETABLE_FLEXIBLE_TRANSPORT_MERGING("TimetableFlexibleTransportMerging"), | ||
|
||
/** | ||
* Profile for validating swedish timetable data. | ||
*/ | ||
TIMETABLE_SWEDEN("TimetableSweden"), | ||
|
||
/** | ||
* Profile for stop dataset. | ||
*/ | ||
STOP("Stop"); | ||
|
||
private final String id; | ||
|
||
ValidationProfile(String id) { | ||
this.id = Objects.requireNonNull(id); | ||
} | ||
|
||
/** | ||
* Return a ValidationProfile for a given name if it exists. | ||
*/ | ||
public static Optional<ValidationProfile> findById(String validationProfile) { | ||
return EnumSet | ||
.allOf(ValidationProfile.class) | ||
.stream() | ||
.filter(element -> element.id().equalsIgnoreCase(validationProfile)) | ||
.findFirst(); | ||
} | ||
|
||
public String id() { | ||
return id; | ||
} | ||
} |
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