title: Do I really need to implement iterator in that case?
body: <p>I need some advice about usage of <code>Iterable&lt;T&gt;</code> in Java.</p>
  
  <p>I have the following class:</p>
  
  <pre><code>public abstract class Validator implements Comparable&lt;Validator&gt;{
      public abstract boolean validate();
      public abstract int getPriority();
  
      @Override
      public int compareTo(Validator o) {
          return getPriority() &gt; o.getPriority() ? -1 :
                  getPriority() == o.getPriority() ? 0 : 
                      1;
      }
  }
  </code></pre>
  
  <p>I need to create a class <code>ValidatorChain</code> as follows:</p>
  
  <pre><code>public class ValidatorChain{
      //Contains Collection&lt;Validator&gt;
  
      // and we can iterate over it with for-each loop in high-to-low priority order
  }
  </code></pre>
  
  <p>Maybe I should just override some instant implementation of <code>Iterable&lt;T&gt;</code> instead of writing my own one from scratch. </p>