title: How to provide class static method as a variable in Java?
body: <p>I am trying to wrap some code into a helper function to be able to reduce the amount of code. Below is a Selenium "Explicit wait" <a href="http://docs.seleniumhq.org/docs/04_webdriver_advanced.jsp" rel="nofollow">example</a>:</p>
  
  <pre><code>WebElement myDynamicElement = (new WebDriverWait(driver, 10))
  .until(ExpectedConditions.presenceOfElementLocated(By.id("myDynamicElement")));
  </code></pre>
  
  <p>where <code>presenceOfElementLocated</code> and <code>id</code> are static methods of the <code>ExpectedConditions</code> and <code>By</code> classes respectively. What I would like to do, is to create a wrapper function that will look something like this:</p>
  
  <pre><code>public void waitForElement(Type condition1, Type by1, String identifier){
      WebElement myDynamicElement = (new WebDriverWait(driver, 10))
     .until(ExpectedConditions.condition1(By.by1("myDynamicElement")));
  }
  </code></pre>
  
  <p>However, obviously I can't just stick the "condition" and "by" directly like above. I know that in Python I would use <code>getattr</code> to return the value of the named attribute of <code>Class.name</code>. </p>
  
  <p>How can I do that in Java?</p>
  
  <p><strong>EDIT1</strong>:
  I would like to call this method in the following manner:</p>
  
  <pre><code>waitForElement(Type? condition, Type? by, String identifier)
  </code></pre>
  
  <p>where:</p>
  
  <p><strong>condition</strong> - one of the Selenium expected conditions
  <strong>by</strong> is  - one of the Selenium by criteria
  <strong>identifier</strong> (or locator) - web element to wait for.</p>
  
  <p><strong>PS</strong> <code>Type?</code> means that I am not sure what should be used here.</p>