net.sf.jga.fn.property
Class InstanceOf<T>

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

public class InstanceOf<T>
extends UnaryFunctor<T,java.lang.Boolean>

Functor that returns true if the argument is an instance of given type.

NOTE: the generic parm T is not related to the class parameter. If there was such a relationship (ie, if the class paramater given to the constructor was declared-- if it were declared Class<T> rather than Class<?>, then the compiler would require that the arguemnt be of the given type to compile code that uses this functor, eliminating the need for the functor in the first plase. Instead, the generic parm is the class of objects that will be tested.

Copyright © 2004-2005 David A. Hall

Author:
David A. Hall
See Also:
Serialized Form

Nested Class Summary
static interface InstanceOf.Visitor
          Interface for classes that may interpret a InstanceOf function.
 
Constructor Summary
InstanceOf(java.lang.Class<?> cl)
          Builds a InstanceOf predicate that tests against the given class.
 
Method Summary
 void accept(Visitor v)
          Calls the Visitor's visit(InstanceOf) method, if it implements the nested Visitor interface.
 java.lang.Boolean fn(T arg)
          Executes the function and returns the result.
 java.lang.Class<?> getTestClass()
           
 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

InstanceOf

public InstanceOf(java.lang.Class<?> cl)
Builds a InstanceOf predicate that tests against the given class.

Throws:
java.lang.IllegalArgumentException - if the class is null.
Method Detail

getTestClass

public java.lang.Class<?> getTestClass()

fn

public java.lang.Boolean fn(T arg)
Description copied from class: UnaryFunctor
Executes the function and returns the result.

Specified by:
fn in class UnaryFunctor<T,java.lang.Boolean>

accept

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

Specified by:
accept in interface Visitable
Overrides:
accept in class Functor<java.lang.Boolean>

toString

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


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