Class IfClosure
- java.lang.Object
-
- org.apache.commons.collections.functors.IfClosure
-
- All Implemented Interfaces:
java.io.Serializable
,Closure
@Deprecated(since="2021-04-30") public class IfClosure extends java.lang.Object implements Closure, java.io.Serializable
Deprecated.Commons Collections 3 is in maintenance mode. Commons Collections 4 should be used instead.Closure implementation acts as an if statement calling one or other closure based on a predicate.- Since:
- Commons Collections 3.0
- See Also:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
execute(java.lang.Object input)
Deprecated.Executes the true or false closure accoring to the result of the predicate.Closure
getFalseClosure()
Deprecated.Gets the closure called when false.static Closure
getInstance(Predicate predicate, Closure trueClosure)
Deprecated.Factory method that performs validation.static Closure
getInstance(Predicate predicate, Closure trueClosure, Closure falseClosure)
Deprecated.Factory method that performs validation.Predicate
getPredicate()
Deprecated.Gets the predicate.Closure
getTrueClosure()
Deprecated.Gets the closure called when true.
-
-
-
Constructor Detail
-
IfClosure
public IfClosure(Predicate predicate, Closure trueClosure)
Deprecated.Constructor that performs no validation. UsegetInstance
if you want that.This constructor creates a closure that performs no action when the predicate is false.
- Parameters:
predicate
- predicate to switch on, not nulltrueClosure
- closure used if true, not null- Since:
- Commons Collections 3.2
-
IfClosure
public IfClosure(Predicate predicate, Closure trueClosure, Closure falseClosure)
Deprecated.Constructor that performs no validation. UsegetInstance
if you want that.- Parameters:
predicate
- predicate to switch on, not nulltrueClosure
- closure used if true, not nullfalseClosure
- closure used if false, not null
-
-
Method Detail
-
getInstance
public static Closure getInstance(Predicate predicate, Closure trueClosure)
Deprecated.Factory method that performs validation.This factory creates a closure that performs no action when the predicate is false.
- Parameters:
predicate
- predicate to switch ontrueClosure
- closure used if true- Returns:
- the
if
closure - Throws:
java.lang.IllegalArgumentException
- if either argument is null- Since:
- Commons Collections 3.2
-
getInstance
public static Closure getInstance(Predicate predicate, Closure trueClosure, Closure falseClosure)
Deprecated.Factory method that performs validation.- Parameters:
predicate
- predicate to switch ontrueClosure
- closure used if truefalseClosure
- closure used if false- Returns:
- the
if
closure - Throws:
java.lang.IllegalArgumentException
- if any argument is null
-
execute
public void execute(java.lang.Object input)
Deprecated.Executes the true or false closure accoring to the result of the predicate.
-
getPredicate
public Predicate getPredicate()
Deprecated.Gets the predicate.- Returns:
- the predicate
- Since:
- Commons Collections 3.1
-
getTrueClosure
public Closure getTrueClosure()
Deprecated.Gets the closure called when true.- Returns:
- the closure
- Since:
- Commons Collections 3.1
-
getFalseClosure
public Closure getFalseClosure()
Deprecated.Gets the closure called when false.- Returns:
- the closure
- Since:
- Commons Collections 3.1
-
-