net.sf.jga.fn.property
Class ConstructUnary<T,R>

java.lang.Object
  extended by net.sf.jga.fn.UnaryFunctor<T,R>
      extended by net.sf.jga.fn.property.ConstructUnary<T,R>
All Implemented Interfaces:
java.io.Serializable, Visitable

public class ConstructUnary<T,R>
extends UnaryFunctor<T,R>

Unary Functor that constructs an object of the given class via a one-argument constructor.

Copyright © 2003 David A. Hall

Author:
David A. Hall
See Also:
Serialized Form

Nested Class Summary
static interface ConstructUnary.Visitor
          Interface for classes that may interpret a ConstructUnary predicate.
 
Constructor Summary
ConstructUnary(java.lang.Class<T> argclass, java.lang.Class<R> ctorclass)
          Builds a functor that will build an object of class ctorclass, given an argument of class argclass.
 
Method Summary
 void accept(Visitor v)
          Calls the Visitor's visit(ConstructUnary) method, if it implements the nested Visitor interface.
 R fn(T arg)
          Builds an object via a one-arg constructor, passing the given value.
 java.lang.String toString()
           
 
Methods inherited from class net.sf.jga.fn.UnaryFunctor
bind, compose, compose, generate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ConstructUnary

public ConstructUnary(java.lang.Class<T> argclass,
                      java.lang.Class<R> ctorclass)
Builds a functor that will build an object of class ctorclass, given an argument of class argclass. The classes passed to the constructor must be assignable to the generic arguments (when generics are in use): ConstructUnary ctor = new ConstructUnary(String.class,Integer.class);

Throws:
java.lang.IllegalArgumentException - if either argument is omitted, or if the constructor cannot be found.
Method Detail

fn

public R fn(T arg)
Builds an object via a one-arg constructor, passing the given value.

Specified by:
fn in class UnaryFunctor<T,R>
Returns:
the object built by the constructor

accept

public void accept(Visitor v)
Calls the Visitor's visit(ConstructUnary) method, if it implements the nested Visitor interface.

Specified by:
accept in interface Visitable
Overrides:
accept in class UnaryFunctor<T,R>

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


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