Java Generics
Posted by
Ben Woodcroft-2 on
Jun 08, 2007; 7:38am
URL: http://imagej.273.s1.nabble.com/Java-Generics-tp3699132.html
Hi all,
This is one for the Java coding folks. I'm just wondering what the opinions
are for implementing
generics<
http://java.sun.com/j2se/1.5.0/docs/guide/language/generics.html>in
the ImageJ code are. Generics only work with Java
1.5+, but since 1.5 is already recommended that is ok?
I would personally find doing things like making an ImageStack a
collection/iterable of ImageProcessors useful, like this:
public class ImageStack<T extends ImageProcessor> implements List<T>{
public T get(int sliceNum){..}
...
}
Then you could do stuff like:
ImageStack<ByteProcessor> stack = new ImageStack<ByteProcessor>();
for(ByteProcessor b : stack){
//do something only ByteProcessors can do
}
Thanks,
ben