title: Drools rule get from a list object that do not match
body: <p>I have a class containing a list. The items in the list have a subtype. I expect that every fact from this class contains a list of items that have the same subtype. I am trying to write a rule that gets all the items coming from the same list and checks whether they have a different subtype. 
  The following attempt fails to compile the last condition:</p>
  
  <pre><code>public class ListContainer {
      private List&lt;MyType&gt; myTypes;
      //getters-setters-hashcode-equals generated by eclipse
      ...
  }
  
  
  
  public class MyType{
      private String subType;
      //getters-setters-hashcode-equals generated by eclipse
      ...
  }
  
  rule "invalidate inconsistent subtypes"
      when
          $list: ListContainer($myTypes: myTypes)
          $myType1 : MyType() from $myTypes
          $myType2 : MyType() from $myTypes
          not($myType1.subType == $myType2.subType)
      then
          //actions
  end
  </code></pre>
  
  <p>The compilation error says it is unable to resolve $myType1.subType 
  I suspect that the items that I get with the keyword from are not casted to the original class. However I am not trying to compile this one, I am just looking for the best rule for this problem.</p>
  
  <p>Thank you very much.</p>
  
  <hr>
  
  <p>Here is the version that compiles thanks to laune comment:</p>
  
  <pre><code>rule "invalidate inconsistent subtypes"
      when
          $list: ListContainer($myTypes: myTypes)
          $myType : MyType( $subType: subType ) from $myTypes
          exists MyType( subType != $subType ) from $myTypes
      then
          //actions
  end
  </code></pre>