-
Notifications
You must be signed in to change notification settings - Fork 52
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
Creating DataHandle<Location> from FileLocation and BytesLocation #468
Comments
I fixed a generics typing issue with public static FileHandle getFileHandle(FileLocation fileLocation) {
Objects.requireNonNull(fileLocation, "Null fileLocation");
FileHandle fileHandle = new FileHandle();
fileHandle.set(fileLocation);
return fileHandle;
}
public static BytesHandle getBytesHandle(BytesLocation bytesLocation) {
Objects.requireNonNull(bytesLocation, "Null bytesLocation");
BytesHandle bytesHandle = new BytesHandle();
bytesHandle.set(bytesLocation);
return bytesHandle;
} And then pass the returned I think your approach to avoid creating a |
Unfortunately, it is not enough! In your SCIFIO TiffParser code, "in" stream is declared as
I cannot change the returning type of this method, for example, to It is obviously a fundamental problem of your generics architecture. I've described it in another issue: |
Most popular situations, when we need DataHandle, are processing files and byte arrays, implemented in the classes FileHandle and BytesHandle. Unfortunately, the only correct way to create the necessary objects is using SciHava context technique:
context.getService(DataHandleService.class).create(location)
But initializing context sub-system requires time and special code. I would be very desirable to avoid Context class in these very simple situation.
I've found necessary solution as a pair of simple functions:
Could you provide such convenient methods inside FileLocation/ByteLocation classes?
Besides, you see that it turned out to be necessary to use @SupressWarning to make necessary
DataHandle<Location>
. Maybe you should rework generics in your module to provide ability to returnDataHandle<Location>
without compiler warnings? Or, at least, please make the methods getFileHandle/getBytesHandle with @SupressWarning a part of your own classes, to avoid your users to write unsafe code.It is a duplicate of the issue scifio/scifio#508 - it seems here is more suitable place. So you may close that issue in SCIFIO project.
The text was updated successfully, but these errors were encountered: