Method-Object pairs in Java
<p>I'd like to create a list of method-object pairs. Each method is a function returning a boolean. Then:</p>

<pre><code>foreach(pair) {
   if method evaluates to true {
      do something with the object
   }
}
</code></pre>

<p>One way of modelling this that I can think of is to have a class <code>Constraint</code> with a method <code>isValid()</code> and for each constraint produce an anonymous class (overriding the <code>isValid()</code> method). I feel like there could be a nicer way. Can you think of any?</p>
