What is it that you're trying to achieve here?  Do you have a Factory
interface for creating Resource?  Are you expecting the Factory method to
always supply a URI?  Or sometimes not supply it?  Or supply it but let it
be null?

sam

On Sun, Jun 19, 2011 at 10:58 PM, cowwoc <[email protected]> wrote:

> Hi,
>
> How can I mix optional parameters into a constructor with
> AssistedInject? For example:
>
> public class Resource
> {
>  @Inject
>  public Resource(@Assisted URI uri, Helper helper)
>  {...}
>
>  public static interface Builder
>  {
>    /**
>     * Create a new resource (uri is null).
>     */
>    Resource create();
>
>    /**
>     * Load an existing resource (uri is non-null).
>     */
>    Resource load(URI uri);
>  }
> }
>
> I tried this:
>
> public class Resource
> {
>  @Inject
>  public Resource(UriHolder uri, Helper helper)
>  {...}
>
>  static class UriHolder
>  {
>        @Inject(optional=true) @Assisted URI value;
>  }
> }
>
> but UriHolder.uri is always null. Any ideas?
>
> Thanks,
> Gili
>
> --
> You received this message because you are subscribed to the Google Groups
> "google-guice" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/google-guice?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.

Reply via email to