Lets say I have a service called Guice service and here is its constructor

public GuiceService(IPayment payment) {
    this.payment = payment;}

And my code used to create it using an Enum

IPayment payment = new PaymentFactory.create(PaymentType.Cash);NaiveService 
naiveService = new NaiveService(payment);

And I had to have a factory implementation somewhere. Something like this

public IPayment create(PaymentType paymentType) {
    IPayment cardPayment = null;
    switch (paymentType) {
        case Cash:
            cardPayment = new CashPayment(100);
            break;
        case Card:
            cardPayment = new CardPayment(10, 100);
            break;
    }
    return cardPayment;

Now I want to use Guice and I guess I want to use FactoryModuleBuilder.

   1. 
   
   What is the way to do it if I have more that one implentation of 
   IPayment.
   (e.g. CardPayment, CashPayment)
   This works for one
   
   install(new FactoryModuleBuilder()
      .implement(IPayment.class, CashPayment.class)
      .build(IPaymentFactory.class));
   
   2. How do I implement the constructor ?
   will it still get IPayment? or will it get the factoryImpl created by 
   Guice?

Thanks

-- 
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 http://groups.google.com/group/google-guice.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-guice/6dd05ff1-112f-4d3f-a494-beeb76217424%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to