Closed vpaturet closed 2 months ago
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 69.47%. Comparing base (
15b49f9
) to head (22ed45e
). Report is 24 commits behind head on dev-2.x.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Summary
This PR makes use of immutable data structures in the timetable snapshot. This ensures that attempts to modify the data structures after the snapshot is committed will fail fast.
In addition the immutable maps created by
Map.copyOf()
andImmutableSetMultimap.copyOf()
cannot contain null keys or values, providing a way to fail fast if these conditions are not fulfilled.To further prevent attempts to modify a published timetable snapshot, methods that modify the states are either made private or are guarded by a condition on the
readOnly
field.Note: It does not seem that in today's code any of these requirements on immutability is broken: the write API is not called after the timetable snapshot is created, null keys and values are not used, the collections are not modified after publication (but the objects they refer to may be modified). The main purpose of this PR is to make these requirements more visible, to make sure they are not broken in the future, and to make reasoning on the timetable snapshot easier.
Issue
No
Unit tests
Added unit tests to check immutability (some existing tests already partially test the public API for immutability. The new tests are more focused on testing only this aspect)
Documentation
No