title: Incompatible types - Found Object when using generics
body: <p>I'm having an issue where the following loop is throwing an error <code>Incompatible types: Required: Workstation, Found: java.lang.Object</code>.</p>
  
  <p>With everything being typed, I can't understand why it's finding an Object instead of the typed object.</p>
  
  <pre><code>private static WorkflowProcess getWorkflowProcessByWorkstationRecursive(Collection&lt;WorkflowProcess&gt; workflowProcesses) {
      for (WorkflowProcess workflowProcess : workflowProcesses) {
          for (Workstation workstation : workflowProcess.getWorkstations()) //ERROR IS HERE
  </code></pre>
  
  <p><strong>WorkflowProcess.java</strong></p>
  
  <pre><code>abstract public class WorkflowProcess&lt;WorkstationType extends Workstation&gt; {
  
      private ArrayList&lt;WorkstationType&gt; workstationList = new ArrayList&lt;WorkstationType&gt;();
  
      public ArrayList&lt;WorkstationType&gt; getWorkstations() {
          return workstationList;
      }
  </code></pre>
  
  <p><strong>ServerWorkflowProcess.java</strong></p>
  
  <pre><code>abstract public class ServerWorkflowProcess extends WorkflowProcess&lt;ServerWorkstation&gt; {
  </code></pre>
  
  <p><strong>ServerWorkstation.java</strong></p>
  
  <pre><code>abstract public class ServerWorkstation extends Workstation&lt;ServerWorkflowProcess&gt; {
  </code></pre>
  
  <p>It gets a little complicated, but essentially the class hierarchy looks like this:</p>
  
  <p><code>SpecificWorkflowProcess</code> extends <code>TypeOfWorkflowProcess&lt;TypeOfWorkstaton&gt;</code> extends <code>WorkflowProcess</code></p>
  
  <p><code>SpecificWorkstation</code> extends <code>TypeOfWorkstation&lt;TypeOfWorkflowProcess&gt;</code> extends <code>Workstation</code></p>
  
  <p><code>WorkflowProcesses</code> to <code>Workstation</code> = One to many</p>