title: Abstract static factory method [getInstance()] in Java?
body: <p>Of course, the following doesn't work in Java (no abstract static methods)...</p>
  
  <pre><code>public abstract class Animal {
      public abstract static Animal getInstance(byte[] b);
  }
  
  public class Dog extends Animal {
      @Override
      public static Dog getInstance(byte[] b) {
          // Woof.
          return new Dog(...);
      }
  }
  
  public class Cat extends Animal {
      @Override
      public static Cat getInstance(byte[] b) {
          // Meow.
          return new Cat(...);
      }
  }
  </code></pre>
  
  <p>What's the correct way of requiring that <code>Animal</code> classes have a static <code>getInstance</code> method that instantiates itself? This method should be static; a "normal" abstract method doesn't make sense here.</p>