Beispiel #1
0
 /**
  * Create a new Closure that calls one of the closures depending
  * on the predicates.
  * <p>
  * The closure at array location 0 is called if the predicate at array
  * location 0 returned true. Each predicate is evaluated
  * until one returns true. If no predicates evaluate to true, the default
  * closure is called.
  *
  * @see org.apache.commons.collections.functors.SwitchClosure
  *
  * @param predicates  an array of predicates to check, not null
  * @param closures  an array of closures to call, not null
  * @param defaultClosure  the default to call if no predicate matches
  * @return the <code>switch</code> closure
  * @throws IllegalArgumentException if the either array is null
  * @throws IllegalArgumentException if any element in the arrays is null
  * @throws IllegalArgumentException if the arrays are different sizes
  */
 public static Closure switchClosure(Predicate[] predicates, Closure[] closures, Closure defaultClosure)
 {
     return(SwitchClosure.getInstance(predicates, closures, defaultClosure));
 }
Beispiel #2
0
 /**
  * Create a new Closure that calls one of the closures depending
  * on the predicates.
  * <p>
  * The Map consists of Predicate keys and Closure values. A closure
  * is called if its matching predicate returns true. Each predicate is evaluated
  * until one returns true. If no predicates evaluate to true, the default
  * closure is called. The default closure is set in the map with a
  * null key. The ordering is that of the iterator() method on the entryset
  * collection of the map.
  *
  * @see org.apache.commons.collections.functors.SwitchClosure
  *
  * @param predicatesAndClosures  a map of predicates to closures
  * @return the <code>switch</code> closure
  * @throws IllegalArgumentException if the map is null
  * @throws IllegalArgumentException if the map is empty
  * @throws IllegalArgumentException if any closure in the map is null
  * @throws ClassCastException  if the map elements are of the wrong type
  */
 public static Closure switchClosure(java.util.Map <Object, Object> predicatesAndClosures)
 {
     return(SwitchClosure.getInstance(predicatesAndClosures));
 }
Beispiel #3
0
 /**
  * Create a new Closure that calls one of the closures depending
  * on the predicates.
  * <p>
  * The closure at array location 0 is called if the predicate at array
  * location 0 returned true. Each predicate is evaluated
  * until one returns true.
  *
  * @see org.apache.commons.collections.functors.SwitchClosure
  *
  * @param predicates  an array of predicates to check, not null
  * @param closures  an array of closures to call, not null
  * @return the <code>switch</code> closure
  * @throws IllegalArgumentException if the either array is null
  * @throws IllegalArgumentException if any element in the arrays is null
  * @throws IllegalArgumentException if the arrays are different sizes
  */
 public static Closure switchClosure(Predicate[] predicates, Closure[] closures)
 {
     return(SwitchClosure.getInstance(predicates, closures, null));
 }