title: How to convert list of objects to list of interfaces?
body: <p>I have some class that works with interfaces:</p>
  
  <p>Here is the interface:</p>
  
  <pre><code>public interface Orderable
  {
      int getOrder()
      void setOrder()
  }
  </code></pre>
  
  <p>Here is the worker class:</p>
  
  <pre><code>public class Worker
  {
     private List&lt;Orderable&gt; workingList;
  
     public void setList(List&lt;Orderable&gt; value) {this.workingList=value;}
  
     public void changePlaces(Orderable o1,Orderable o2)
     {
       // implementation that make o1.order=o2.order and vice versa
     }
  }
  </code></pre>
  
  <p>Here is an object that implements the interface:</p>
  
  <pre><code>public class Cat implements Orderable
  {
      private int order;
  
      public int getOrder()
      {
        return this.order;
      }
  
      public void setOrder(int value)
      {
        this.order=value;
      }
  
      public Cat(String name,int order)
      {
         this.name=name;
         this.order=order;
      }
  }
  </code></pre>
  
  <p>In the main procedure I create a list of cats. I use <a href="http://www.glazedlists.com/" rel="noreferrer">glazed lists</a> to dynamically update controls when the list is changed and when a control model is created with this list.</p>
  
  <p>The goal is to transfer this list to a worker object, so I can add some new cat to the list in the main procedure, and the worker will know about it without setting its list property again (list is same object in main proc and in worker). But when I call <code>worker.setList(cats)</code> it alerts about expecting an Orderable, but getting a Cat... but Cat implements Orderable. How do I solve this?</p>
  
  <p>Here is the main code:</p>
  
  <pre><code>void main()
  {
     EventList&lt;Cat&gt; cats=new BasicEventList&lt;Cat&gt;();
  
     for (int i=0;i&lt;10;i++)
     {
        Cat cat=new Cat("Maroo"+i,i);
        cats.add(cat);
     }
  
     Worker worker=new Worker(); 
     worker.setList(cats); // wrong!
     // and other very useful code
  }
  </code></pre>