title: Guice - how to implement a factory that returns different implementations
body: <p>Lets say I have a service called Guice service and here is its constructor</p>
  
  <pre><code>public GuiceService(IPayment payment) {
      this.payment = payment;
  }
  </code></pre>
  
  <p>And my code used to create it using an Enum</p>
  
  <pre><code>IPayment payment = new PaymentFactory.create(PaymentType.Cash);
  NaiveService naiveService = new NaiveService(payment);
  </code></pre>
  
  <p>And I had to have a factory implementation somewhere. Something like this </p>
  
  <pre><code>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;
  </code></pre>
  
  <p>Now I want to use Guice and I guess I want to use FactoryModuleBuilder.  </p>
  
  <ol>
  <li><p>What is the way to do it if I have more that one implentation of IPayment.<br>
  (e.g. CardPayment, CashPayment)<br>
  This works for one  </p>
  
  <pre><code>install(new FactoryModuleBuilder()
     .implement(IPayment.class, CashPayment.class)
     .build(IPaymentFactory.class));
  </code></pre></li>
  <li>How do I implement the constructor ?<br>
  will it still get IPayment? or will it get the factoryImpl created by Guice?</li>
  </ol>
  
  <p>Thanks</p>