ix.util
Class Fn

java.lang.Object
  extended by ix.util.Fn

public final class Fn
extends java.lang.Object

Function utilities

See Also:
Collect, Strings, Util.makeInstance(Class), Util.makeInstance(Class, Object...)

Field Summary
static Predicate1 alwaysFalse
          A predicate that returns false for any object.
static Predicate1 alwaysTrue
          A predicate that returns true for any object.
static Function1 identity
          The identity function.
 
Method Summary
static Function1 accessor(java.lang.Class c, java.lang.String methodName)
          Returns a function that calls the 0-argument method specified by a class and method name.
static Function1 always(java.lang.Object value)
          Returns a function that always returns the same value.
static java.lang.Object apply(java.lang.Object object, java.lang.reflect.Method meth, java.lang.Object[] arguments)
          Calls the indicated method.
static java.lang.Object apply(java.lang.Object object, java.lang.String methodName, java.util.List arguments)
          Calls the indicated method.
static java.lang.Object apply(java.lang.Object object, java.lang.String methodName, java.lang.Object[] arguments)
          Calls the indicated method.
static java.lang.Object applyStatic(java.lang.Class c, java.lang.String methodName, java.util.List arguments)
          Calls the indicated static method.
static java.lang.Object applyStatic(java.lang.Class c, java.lang.String methodName, java.lang.Object[] arguments)
          Calls the indicated static method.
static java.lang.reflect.Method getMethod(java.lang.Class c, java.lang.String methodName, java.lang.Class[] argSig)
          Returns the specified method if it exists, else null.
static java.lang.reflect.Method getMethod(java.lang.Object object, java.lang.String methodName, java.lang.Object[] arguments)
          Returns the specified method if it exists, else null.
static Predicate1 isInstanceOf(java.lang.Class c)
          Returns a predicate that test whether an object is an instance of the specified class.
static Predicate1 negate(Predicate1 p)
          Returns a predicate that returns false when the given predicate returns true, and true when it returns false.
static java.lang.Class objectClass(java.lang.Class type)
          Maps primitive classes (TYPEs) to the corresponding object classes, and other classes to themselves.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

alwaysTrue

public static final Predicate1 alwaysTrue
A predicate that returns true for any object.


alwaysFalse

public static final Predicate1 alwaysFalse
A predicate that returns false for any object.


identity

public static final Function1 identity
The identity function.

Method Detail

apply

public static java.lang.Object apply(java.lang.Object object,
                                     java.lang.String methodName,
                                     java.util.List arguments)
Calls the indicated method.

See Also:
getMethod(Class c, String methodName, Class[] argSig)

apply

public static java.lang.Object apply(java.lang.Object object,
                                     java.lang.String methodName,
                                     java.lang.Object[] arguments)
Calls the indicated method.

See Also:
getMethod(Class c, String methodName, Class[] argSig)

apply

public static java.lang.Object apply(java.lang.Object object,
                                     java.lang.reflect.Method meth,
                                     java.lang.Object[] arguments)
Calls the indicated method.


applyStatic

public static java.lang.Object applyStatic(java.lang.Class c,
                                           java.lang.String methodName,
                                           java.util.List arguments)
Calls the indicated static method.

See Also:
getMethod(Class c, String methodName, Class[] argSig)

applyStatic

public static java.lang.Object applyStatic(java.lang.Class c,
                                           java.lang.String methodName,
                                           java.lang.Object[] arguments)
Calls the indicated static method.

See Also:
getMethod(Class c, String methodName, Class[] argSig)

getMethod

public static java.lang.reflect.Method getMethod(java.lang.Object object,
                                                 java.lang.String methodName,
                                                 java.lang.Object[] arguments)
Returns the specified method if it exists, else null.

See Also:
getMethod(Class c, String methodName, Class[] argSig)

getMethod

public static java.lang.reflect.Method getMethod(java.lang.Class c,
                                                 java.lang.String methodName,
                                                 java.lang.Class[] argSig)
Returns the specified method if it exists, else null.


objectClass

public static java.lang.Class objectClass(java.lang.Class type)
Maps primitive classes (TYPEs) to the corresponding object classes, and other classes to themselves.


accessor

public static Function1 accessor(java.lang.Class c,
                                 java.lang.String methodName)
Returns a function that calls the 0-argument method specified by a class and method name.


always

public static Function1 always(java.lang.Object value)
Returns a function that always returns the same value.


negate

public static Predicate1 negate(Predicate1 p)
Returns a predicate that returns false when the given predicate returns true, and true when it returns false.


isInstanceOf

public static Predicate1 isInstanceOf(java.lang.Class c)
Returns a predicate that test whether an object is an instance of the specified class.