title: Dagger 2: Injecting user inputted parameter into object
body: <p>Say I have a class <strong>Util</strong> that takes in a object - an instance of class <strong>Validator</strong>. </p>
  
  <p>Since I want to avoid instantiating the Validator class within Util, I pass it in via a constructor: </p>
  
  <pre><code>public class Util {
  
     @Inject
     public Util(Validator validator) {
  
     }
  
  
  }
  </code></pre>
  
  <p>I have a module that provides the Validator instance:</p>
  
  <pre><code>@Provides
  @Singleton
  Validator provideValidator() {
      return Validator.getInstance();
  }
  </code></pre>
  
  <p>and an instance of the Util class:</p>
  
  <pre><code>@Provides
  Util provideUtil(Validator validator) {
      return new Util(validator);
  }
  </code></pre>
  
  <p>I have a component wired up that would give me an instance of Util:</p>
  
  <pre><code>Util getUtil()
  </code></pre>
  
  <p>so within my activity, I could call it like: </p>
  
  <pre><code>Util myUtil = getComponent.getUtil();
  </code></pre>
  
  <p>All of that works fine - myUtil has a proper instance of Validator class when instantiated. </p>
  
  <p>Now I want to pass in a String variable named <strong>address</strong> (which is user input via a UI). I want to change the constructor so I pass in both an instance of Validator and the user inputted String:</p>
  
  <pre><code>@Inject
  public Util(Validator validator, String address) {
  
  }
  </code></pre>
  
  <p>I just can't get my head around how to pass that 2nd parameter. Can someone tell me how? </p>
  
  <p>Ideally, I want to instantiate Util like:</p>
  
  <pre><code>Util myUtil = getComponent.getUtil(txtAddress.getText());
  </code></pre>