net.sf.jga.fn
Class UnaryFunctor<T,R>

java.lang.Object
  extended by net.sf.jga.fn.Functor<R>
      extended by net.sf.jga.fn.UnaryFunctor<T,R>
All Implemented Interfaces:
java.io.Serializable, Visitable
Direct Known Subclasses:
Accumulate, All, AndUnary, Any, ApplyUnary, ArrayUnary, Average, Between, Bind1st, Bind2nd, BitwiseNot, Cast, ChainUnary, CompareProperty, ComposeUnary, CompoundUnary, ConditionalUnary, ConstantUnary, Construct, ConstructUnary, Count, DefaultFormat, ForEach, FormatValue, Generate1st, Generate2nd, GenerateUnary, GetField, GetProperty, Identity, InstanceOf, InvokeNoArgMethod, LogicalNot, Match, MaxValue, MinValue, Negate, OrUnary, ParseFormat, UnaryNegate, ValueOf

public abstract class UnaryFunctor<T,R>
extends Functor<R>
implements java.io.Serializable, Visitable

A Function Object that takes one argument and returns a result. The argument is of type T, and the result is of type R.

Copyright © 2002-2005 David A. Hall

Author:
David A. Hall
See Also:
Serialized Form

Constructor Summary
UnaryFunctor()
           
 
Method Summary
 Generator<R> bind(T val)
          FactoryMethod that binds the argument arguments to this function to a specific value.
 Functor<R> bind0th(java.lang.Object arg0, java.lang.Object... args)
          Binds the given values to this functor, starting from the first argument.
 Functor<R> bindNth(int idx, java.lang.Object arg0, java.lang.Object... args)
          Binds the given values to this functor, starting from the given index.
<F1,F2> BinaryFunctor<F1,F2,R>
compose(BinaryFunctor<F1,F2,T> f)
          FactoryMethod that creates a BinaryFunctor that passes its arguments to the given functor, and uses the result as the argument to this function.
 Functor<R> compose(Functor<T> f)
          FactoryMethod that creates a BinaryFunctor that passes its arguments to the given functor, and uses the result as the argument to this function.
<F> UnaryFunctor<F,R>
compose(UnaryFunctor<F,T> f)
          FactoryMethod that creates a UnaryFunctor that passes its argument to the given functor, and uses the result as the argument to this function.
 Functor<R> composeNth(int idx, BinaryFunctor<?,?,?> bf)
          Computes the argument at the given index from the pair of arguments starting at the given index
 Functor<R> composeNth(int idx, UnaryFunctor<?,?> uf)
          Modifies the argument at the given index to this functor
 R eval(java.lang.Object... args)
          Executes the function and returns the result.
abstract  R fn(T arg)
          Executes the function and returns the result.
 Generator<R> generate(Generator<T> gen)
          FactoryMethod that creates a Generator to create the argument to this function.
 Functor<R> generateNth(int idx, Generator<?> gen)
          Generates the argument at the given index to this functor
 
Methods inherited from class net.sf.jga.fn.Functor
accept
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.sf.jga.fn.Visitable
accept
 

Constructor Detail

UnaryFunctor

public UnaryFunctor()
Method Detail

fn

public abstract R fn(T arg)
Executes the function and returns the result.


compose

public <F> UnaryFunctor<F,R> compose(UnaryFunctor<F,T> f)
FactoryMethod that creates a UnaryFunctor that passes its argument to the given functor, and uses the result as the argument to this function. Given argument x, the new functor will return fnthis(f(x)))


compose

public <F1,F2> BinaryFunctor<F1,F2,R> compose(BinaryFunctor<F1,F2,T> f)
FactoryMethod that creates a BinaryFunctor that passes its arguments to the given functor, and uses the result as the argument to this function. Given arguments x and y, the new functor will return fnthis(f(x,y)))


compose

public Functor<R> compose(Functor<T> f)
FactoryMethod that creates a BinaryFunctor that passes its arguments to the given functor, and uses the result as the argument to this function. Given arguments x0, x1, ..., the new functor will return fnthis(f(x0,x0,...)))


generate

public Generator<R> generate(Generator<T> gen)
FactoryMethod that creates a Generator to create the argument to this function. The new functor will return fnthis(fn()).


bind

public Generator<R> bind(T val)
FactoryMethod that binds the argument arguments to this function to a specific value. The new functor will return fnthis(val).


eval

public R eval(java.lang.Object... args)
Executes the function and returns the result.

Specified by:
eval in class Functor<R>

bind0th

public Functor<R> bind0th(java.lang.Object arg0,
                          java.lang.Object... args)
Binds the given values to this functor, starting from the first argument.

Overrides:
bind0th in class Functor<R>
Parameters:
arg0 -
args -
Returns:

bindNth

public Functor<R> bindNth(int idx,
                          java.lang.Object arg0,
                          java.lang.Object... args)
Binds the given values to this functor, starting from the given index.

Overrides:
bindNth in class Functor<R>
Parameters:
idx -
arg0 -
args -
Returns:

generateNth

public Functor<R> generateNth(int idx,
                              Generator<?> gen)
Generates the argument at the given index to this functor

Overrides:
generateNth in class Functor<R>
Parameters:
idx -
arg0 -
args -
Returns:

composeNth

public Functor<R> composeNth(int idx,
                             UnaryFunctor<?,?> uf)
Modifies the argument at the given index to this functor

Overrides:
composeNth in class Functor<R>
Parameters:
idx -
arg0 -
args -
Returns:

composeNth

public Functor<R> composeNth(int idx,
                             BinaryFunctor<?,?,?> bf)
Computes the argument at the given index from the pair of arguments starting at the given index

Overrides:
composeNth in class Functor<R>
Parameters:
idx -
arg0 -
args -
Returns:


Copyright © 2002-2006 David A. Hall. All Rights Reserved.