title: can i avoid this casting warning?
body: <p>lets say i have this interface</p>
  
  <pre><code>public interface HavingName {
      HavingName withName(String name);
      String getName();
  }
  </code></pre>
  
  <p>there are multiple implementations of this interface, each one implementing the factory method  <code>withName</code> that returns a new instance of its type, only with the new name.</p>
  
  <p>now i want to write a NameSanitizer that can iterate over a list of concrete HavingName instances and sanitize each name according to some rule </p>
  
  <pre><code>class NameSanitizer {
  
      public &lt;T extends HavingName&gt; List&lt;T&gt; sanitizeNames(List&lt;T&gt; lines) {
          return FluentIterable.from(lines).transform(new Function&lt;T, T&gt;() {
              @Override
              public T apply(T line) {
                  return sanitizeName(line);
              }
          }).toList();
      }
  
      // TODO: how to avoid this casting warning?
      private &lt;T extends HavingName&gt; T sanitizeName(T line) {
          final String name = line.getName();
          return shouldSanitize(name) ?
                  (T) line.withDisplayName(sanitize(name)) : line;
      }
  }
  </code></pre>
  
  <p>i'd love to know if their was any way to avoid the casting warning</p>