title: Generating all binary numbers based on the pattern
body: <p>Given a pattern , we need to generate all possible binary numbers by filling the missing places in the pattern by 0 and 1.</p>
  
  <pre><code>E.g. Pattern = "x1x";
  Output =  [010, 110, 011, 111]
  </code></pre>
  
  <p>I solved it by creating a method <code>calculate</code>.</p>
  
  <pre><code>public static List&lt;String&gt; calculate(String input, int currentIndex) {
      List&lt;String&gt; result = new ArrayList&lt;String&gt;();
      if(currentIndex &gt; input.length()-1) {
          result.add("");
          return result;
      }
      for(String fragment: calculate(input, currentIndex + 1)) {
          if(input.charAt(currentIndex)=='x') {
              result.add('0' + fragment);
              result.add('1' + fragment);
          }
          else {
              result.add(input.charAt(currentIndex) + fragment);
          }
      }
      return result;
  }
  </code></pre>
  
  <p>Is there some way in which we can leverage the given pattern and design a much Faster and/or cleaner solution. I already know that non-recursive solution will be better. Java 8 features are also welcome.</p>