net.sf.staccatocommons.lang.block
Class Block<T>

java.lang.Object
  extended by net.sf.staccatocommons.lang.function.AbstractDelayable<T,Void>
      extended by net.sf.staccatocommons.lang.block.Block<T>
Type Parameters:
T -
All Implemented Interfaces:
net.sf.staccatocommons.defs.Applicable<T,Void>, net.sf.staccatocommons.defs.Delayable<T,Void>, net.sf.staccatocommons.defs.Executable<T>, net.sf.staccatocommons.defs.partial.NullSafeAware<Block<T>>
Direct Known Subclasses:
Empty, TopLevelBlock

public abstract class Block<T>
extends AbstractDelayable<T,Void>
implements net.sf.staccatocommons.defs.Executable<T>, net.sf.staccatocommons.defs.partial.NullSafeAware<Block<T>>

An abstract, one argument code block, that implements Executable

Author:
flbulgarelli

Constructor Summary
Block()
           
 
Method Summary
 Void apply(T arg)
           
 void exec(T argument)
          Executes this block.
 Block<T> nullSafe()
           
protected  void softExec(T argument)
          Executes this block, potentially throwing a checked Throwable
 Block<T> then(net.sf.staccatocommons.defs.Executable<? super T> other)
          Chains this block with the given executable, creating a new Block that executes this one and then the another one.
 String toString()
           
 
Methods inherited from class net.sf.staccatocommons.lang.function.AbstractDelayable
delayed, delayedValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Block

public Block()
Method Detail

exec

public void exec(@NonNull
                 T argument)
Executes this block. This implementation just invokes softExec(Object), and softens any exception it may throw. Subclasses may override this behavior.

Specified by:
exec in interface net.sf.staccatocommons.defs.Executable<T>

softExec

protected void softExec(T argument)
                 throws Throwable
Executes this block, potentially throwing a checked Throwable

Parameters:
argument -
Throws:
Exception
Throwable
See Also:
exec(Object)

apply

public Void apply(T arg)
Specified by:
apply in interface net.sf.staccatocommons.defs.Applicable<T,Void>

nullSafe

public Block<T> nullSafe()
Specified by:
nullSafe in interface net.sf.staccatocommons.defs.partial.NullSafeAware<Block<T>>

then

@NonNull
public Block<T> then(@NonNull
                             net.sf.staccatocommons.defs.Executable<? super T> other)
Chains this block with the given executable, creating a new Block that executes this one and then the another one.

Parameters:
other - the block to execute after this
Returns:
a new block that first invokes execute on this, and then on the Executable provided

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2010-2012 Staccatocommons. All Rights Reserved.