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

java.lang.Object
  extended by net.sf.jga.fn.Functor<R>
      extended by net.sf.jga.fn.Generator<R>
          extended by net.sf.jga.fn.property.ConstructDefault<R>
All Implemented Interfaces:
java.io.Serializable, Visitable

public class ConstructDefault<R>
extends Generator<R>

Generator that constructs an object of the given class using its default constructor.

Copyright © 2004-2005 David A. Hall

Author:
David A. Hall
See Also:
Serialized Form

Nested Class Summary
static interface ConstructDefault.Visitor
          Interface for classes that may interpret a ConstructDefault functor.
 
Constructor Summary
ConstructDefault(java.lang.Class<R> ctorclass)
          Builds a generator that will return instances of the class ctorclass, built using the default constructor.
 
Method Summary
 void accept(Visitor v)
          Calls the Visitor's visit(ConstructDefault) method, if it implements the nested Visitor interface.
 R fn()
          Builds an object via the default constructor
 java.lang.reflect.Constructor<R> getConstructor()
          Lazily loads the constructor
 java.lang.String toString()
           
 
Methods inherited from class net.sf.jga.fn.Generator
bind0th, bindNth, eval
 
Methods inherited from class net.sf.jga.fn.Functor
composeNth, composeNth, generateNth
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ConstructDefault

public ConstructDefault(java.lang.Class<R> ctorclass)
Builds a generator that will return instances of the class ctorclass, built using the default constructor.

Throws:
java.lang.IllegalArgumentException - if the constructor cannot be found
java.lang.IllegalArgumentException - if the class argument is omitted or does not define an accessible default constructor.
Method Detail

getConstructor

public java.lang.reflect.Constructor<R> getConstructor()
                                                throws java.lang.NoSuchMethodException
Lazily loads the constructor

Throws:
java.lang.NoSuchMethodException

fn

public R fn()
Builds an object via the default constructor

Specified by:
fn in class Generator<R>
Returns:
the object built by the constructor

accept

public void accept(Visitor v)
Calls the Visitor's visit(ConstructDefault) 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.