TimurMahammadov / google-collections

Automatically exported from code.google.com/p/google-collections
Apache License 2.0
0 stars 0 forks source link

ForwardingObject should use generics #20

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Why not have ForwardingObject have a generic definition, instead of returning 
java.lang.Object from 
delegate()?

public abstract class ForwardingObject<T> implements Serializable {
    public T delegate() { return delegate; }
}

Original issue reported on code.google.com by sam.bar...@gmail.com on 24 Oct 2007 at 7:46

GoogleCodeExporter commented 9 years ago
Sorry, accidentally posted this as a 'defect'

Original comment by sam.bar...@gmail.com on 24 Oct 2007 at 7:47

GoogleCodeExporter commented 9 years ago
I don't understand what the benefit of doing this is.  Is your goal to make it 
so
that your own forwarding object won't have to override-and-narrow the 
delegate() method?

I think your suggestion would make matters worse. To have any benefit, we'd 
have to
make ALL the forwarding classes generic, so these would now have 2-3 type 
parameters
each, and make T bounded. Then just *using* a forwarding collection will become
suddenly more annoying.

I think that overriding-to-narrow is the most practical thing we can do. I will
reopen this if someone points out something big I'm missing.

Original comment by kevin...@gmail.com on 24 Oct 2007 at 8:12

GoogleCodeExporter commented 9 years ago
You're right, I should've looked at some of the subclasses of ForwardingObject 
before posting. Good stuff.

Original comment by sam.bar...@gmail.com on 24 Oct 2007 at 8:17