I'd like to bump this but with package names rather than visibility 
restrictions.

I too have data models that I don't want to be constructed by giuce, since 
they should almost always be used with @Assisted factory methods bound 
toInstance, but I would really like it if utility classes, (in particular 
and in my case, javafx.stage.DirectoryChooser, a class with an unannotated 
no-arg ctor) could be wired up automatically. 

We use requreAtInjectOnConstructors universally since it completely avoids 
a whole class of bugs around bad-binding of data objects. Right now I'm 
debating making a change toward more IOC with a utility class that wraps 
the Directory chooser (along with a couple other things). I would really 
like the issue to be as simple as "inject the DirectoryChooser, add tests 
to cover currently untested code, devs are happy", but it isn't that simple 
because I'd have to go off to a number of modules and update their 
configuration to 
bind(DirectoryChooser.class).toProvider(DirectoryChooser::new). I don't 
want to make those changes. 

An elegant solution to our problem would be to change the requireAtInject 
to support a package prefix: requireAtInjectonConstructors("com.mycompany"), 
which would require that everything in a package starting with 
"com.mycompany" uses the annotations, and everything in other packages (eg 
javafx.whatever) does not.

Of course, this would change guice's own model from using a single boolean 
flag to using a set of filters, which is obviously substantially more 
complex.

My .02, thanks for reading

-Geoff

On Friday, December 27, 2013 at 6:47:54 PM UTC-8, Tavian Barnes wrote:
>
> Okay good points, I guess I'll just bite the bullet and add them.  It's 
> not too bad anyway, since I'd end up adding constructors to those classes 
> if they ever gained a dependency anyway.  No reason to special-case 
> package-private classes with no dependencies just to save three lines of 
> code each.

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/google-guice.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-guice/50dbccb2-dcd9-44dd-9b03-64113c13c594%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to