Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add utility class for ev events reader #3181

Merged
merged 2 commits into from
Mar 21, 2024

Conversation

nkuehnel
Copy link
Member

@nkuehnel nkuehnel commented Mar 21, 2024

inspired by DrtEventsReaders

public final class DrtEventsReaders {
public static final List<DrtTaskType> STANDARD_TASK_TYPES = List.of(DrtDriveTask.TYPE, DefaultDrtStopTask.TYPE,
DrtStayTask.TYPE, EmptyVehicleRelocator.RELOCATE_VEHICLE_TASK_TYPE);
public static MatsimEventsReader createEventsReader(EventsManager eventsManager,
DrtTaskType... nonStandardTaskTypes) {
MatsimEventsReader reader = new MatsimEventsReader(eventsManager);
var taskTypeByString = StreamEx.of(STANDARD_TASK_TYPES)
.append(nonStandardTaskTypes)
.collect(toImmutableMap(DrtTaskType::name, type -> type));
Map<String, CustomEventMapper> customEventMappers = ImmutableMap.<String, CustomEventMapper>builder()
.putAll(DvrpEventsReaders.createCustomEventMappers(taskTypeByString::get))
.put(DrtRequestSubmittedEvent.EVENT_TYPE, DrtRequestSubmittedEvent::convert)
.build();
customEventMappers.forEach(reader::addCustomEventMapper);
return reader;
}
}

@nkuehnel nkuehnel merged commit 4e058da into matsim-org:master Mar 21, 2024
46 checks passed
@nkuehnel nkuehnel deleted the evEventReaders branch March 21, 2024 12:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant