net.sf.jga.fn.property
Class Construct<R>

java.lang.Object
  extended by net.sf.jga.fn.Functor<R>
      extended by net.sf.jga.fn.UnaryFunctor<java.lang.Object[],R>
          extended by net.sf.jga.fn.property.Construct<R>
All Implemented Interfaces:
java.io.Serializable, Visitable

public class Construct<R>
extends UnaryFunctor<java.lang.Object[],R>

Unary Functor that constructs an object of the given class. The functor argument is an array containing the arguments to the class' constructor.

Copyright © 2003-2005 David A. Hall

Author:
David A. Hall
See Also:
Serialized Form

Nested Class Summary
static interface Construct.Visitor
          Interface for classes that may interpret a Construct predicate.
 
Constructor Summary
Construct(java.lang.Class<?>[] argclasses, java.lang.Class<R> ctorclass)
          Builds a functor that will build an object of class ctorclass, given arguments of classes in argclasses.
Construct(java.lang.Class<R> ctorclass, java.lang.Class<?>... argclasses)
          Builds a functor that will build an object of class ctorclass, given arguments of classes in argclasses.
Construct(java.lang.reflect.Constructor<R> ctor)
          Builds a functor that will build an object using the given constructor.
 
Method Summary
 void accept(Visitor v)
          Calls the Visitor's visit(Construct) method, if it implements the nested Visitor interface.
 R fn(java.lang.Object[] args)
          Builds an object via the designated constructor, passing the given array of argument values.
 java.lang.reflect.Constructor<R> getConstructor()
          Lazy loads the constructor (used if the functor is called after deserialization)
 java.lang.String toString()
           
 
Methods inherited from class net.sf.jga.fn.UnaryFunctor
bind, bind0th, bindNth, compose, compose, compose, composeNth, composeNth, eval, generate, generateNth
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Construct

public Construct(java.lang.Class<R> ctorclass,
                 java.lang.Class<?>... argclasses)
Builds a functor that will build an object of class ctorclass, given arguments of classes in argclasses.

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

Construct

public Construct(java.lang.Class<?>[] argclasses,
                 java.lang.Class<R> ctorclass)
Builds a functor that will build an object of class ctorclass, given arguments of classes in argclasses.

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

Construct

public Construct(java.lang.reflect.Constructor<R> ctor)
Builds a functor that will build an object using the given constructor.

Throws:
java.lang.IllegalArgumentException - if the constructor is omitted.
Method Detail

getConstructor

public java.lang.reflect.Constructor<R> getConstructor()
                                                throws java.lang.NoSuchMethodException
Lazy loads the constructor (used if the functor is called after deserialization)

Throws:
java.lang.NoSuchMethodException

fn

public R fn(java.lang.Object[] args)
Builds an object via the designated constructor, passing the given array of argument values.

Specified by:
fn in class UnaryFunctor<java.lang.Object[],R>
Returns:
the object built by the constructor

accept

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

Specified by:
accept in interface Visitable
Overrides:
accept in class Functor<R>

toString

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


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