Package org.apache.commons.collections4

# Interface Closure<T>

Type Parameters:
  `T` - The type of the input to the operation.

All Superinterfaces:
  `Consumer<T>`

All Known Implementing Classes:
  `CatchAndRethrowClosure`, `ChainedClosure`, `ExceptionClosure`, `ForClosure`, `IfClosure`, `NOPClosure`, `SwitchClosure`, `TransformerClosure`, `WhileClosure`

public interface Closure<T> extends Consumer<T>
Defines a functor interface implemented by classes that do something.

A `Closure` represents a block of code which is executed from inside some block, function or iteration. It operates an input object.

Standard implementations of common closures are provided by `ClosureUtils`. These include method invocation and for/while loops.

Since:
  1.0 This will be deprecated in 5.0 in favor of `Supplier`.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `default void`
  `accept(T input)`
  `void`
  `execute(T input)`
  Performs an action on the specified input object.

  ### Methods inherited from interface java.util.function.Consumer

  `andThen`

- ## Method Details

  - ### accept

    default void accept(T input)
    Specified by:
      `accept` in interface `Consumer<T>`

  - ### execute

    void execute(T input)
    Performs an action on the specified input object.
    Parameters:
      `input` - The input to execute on.
    Throws:
      `ClassCastException` - (runtime) if the input is the wrong class.
      `IllegalArgumentException` - (runtime) if the input is invalid.
      `FunctorException` - (runtime) if any other error occurs.