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

Improve interface for loading and writing mapping files #2

Closed
wants to merge 3 commits into from
Closed

Conversation

sciwhiz12
Copy link

This PR improves the way that IMappingFiles and INamedMappingFiles are loaded and saved.

Instead of being limited to reading from a File or InputStream and writing to a Path, the loading and writing interfaces are now expanded. I(Named)MappingFiles, in addition to being readable from Files and InputStreams (to maintain binary compatibility), can now be read from a Path or Reader, as well as from a raw List<String> (helpful for manipulating mapping files in memory).

I(Named)MappingFile now write to a List<String> instead of directly to a Path, which is helpful for passing mapping data in memory without need to write to then read from disk. The method of writing to a Path is kept in, both because it is useful and to remain binary compatibility.

Also fixed a bug when writing to a Path with no parent directory (which is possible when using an in-memory FileSystem like Jimfs) would cause a NullPointerException due to the Files.createDirectories call.

IMappingFile and INamedMappingFile can now be loaded from and written as a
List<String>, for greater flexibility. They can also be loaded from a Path or Reader.
@LexManos
Copy link
Member

Sorry, flat out forgot about this.
General thing is, I wanna keep the API as simple as possible. If you want to read/write to anything beyond a File, you can do it via Stream.
However we should move the write function to return the data like you have, so that you can save it wherever you wish.
Maybe next breaking change. (Along with #4)

@sciwhiz12 sciwhiz12 closed this Jun 27, 2023
@sciwhiz12 sciwhiz12 deleted the nio branch June 27, 2023 07:30
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.

2 participants