title: How shall one implement the null object pattern in generics?
body: <p>I like the idea of the <a href="https://en.wikipedia.org/wiki/Null_Object_pattern" rel="nofollow">null object pattern</a> and force me to use it until it really feels normal and good. At the moment I don't see how to use it in generic types. I know the possibility to define a second generic type and to pass in the class to construct a default object, but this feels really too much overhead for this pattern. Is there a good way?</p>
  
  <pre><code>public class GenericExample&lt;T&gt; {
      public static final GenericExample NULL = ???;
  
      private T attribute;
  
      public GenericExample(T attribute) {
          this.attribute = attribute;
      }
  }
  
  public class HoldGeneric {
      private GenericExample&lt;String&gt; name = GenericExample.NULL;
  
      public initLater(String name) {
          this.name = new GenericExample&lt;String&gt;(name);
      }
  }
  </code></pre>