Skip to content

RandomAccessibleIntervalView type variables hinder extension #377

@gselzer

Description

@gselzer

Hi all!

Over in imglib2-meta I've been working on a Dataset class which will group a RandomAccessible together with metadata. Our goal, for metadata-preserving manipulation, is to make Dataset a RandomAccessibleView i.e.

public interface Dataset<T, V extends RandomAccessible<T>> extends RandomAccessibleView<T, Dataset<T, V>> {
	@Override
	default V delegate() {
		return data();
	} 
}

Most of the inherited methods here pose no problem. The one that does, however, is RandomAccessibleView.interval, which forces the return of some RandomAccessibleIntervalView. Since we want the returned object to have the metadata as well, we'd need to return a subclass of RandomAccessibleIntervalView and Dataset - maybe:

public interface DatasetInterval<T, V extends RandomAccessibleInterval<T>> extends RandomAccessibleIntervalView<T>, Dataset<T, V> {
	@Override
	default V delegate() {
		return data();
	} 
}

Unfortunately, this is not possible, because RandomAccessibleIntervalView binds the T type parameter to RandomAccessibleIntervalView<T>, which will be incompatible with any subclass that does not extend RandomAccessibleView<T, RandomAccessibleIntervalView<T>>.

The fix

Ideally, I think RandomAccessibleIntervalView would provide a second type parameter that would allow for extension, though this would be a break in compatibility.

Thoughts @tpietzsch @minnerbe?

EDIT: There are similar conversations to be had with RealRandomAccessibleView

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions