Package org.apache.cayenne.util
Class Invocation
- java.lang.Object
-
- org.apache.cayenne.util.Invocation
-
public class Invocation extends Object
Invocation represents a dynamic method invocation bound to a specific target. The target is kept with a WeakReference and can therefore be reclaimed by the Garbage Collector.
-
-
Constructor Summary
Constructors Constructor Description Invocation(Object target, String methodName)Constructor for an Invocation without arguments in the target's method.Invocation(Object target, String methodName, Class parameterType)Constructor for an Invocation with a single argument in the target's method.Invocation(Object target, String methodName, Class[] parameterTypes)Constructor for an Invocation with arbitrary arguments in the target's method.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object obj)booleanfire()Invoke the target's method without any arguments.booleanfire(Object argument)Invoke the target's method with a single argument.booleanfire(Object[] arguments)Invoke the target's method with an arbitrary number of arguments.MethodgetMethod()Class[]getParameterTypes()ObjectgetTarget()inthashCode()
-
-
-
Constructor Detail
-
Invocation
public Invocation(Object target, String methodName) throws NoSuchMethodException
Constructor for an Invocation without arguments in the target's method.- Throws:
NoSuchMethodException- See Also:
Invocation(Object, String, Class[])
-
Invocation
public Invocation(Object target, String methodName, Class parameterType) throws NoSuchMethodException
Constructor for an Invocation with a single argument in the target's method.- Throws:
NoSuchMethodException- See Also:
Invocation(Object, String, Class[])
-
Invocation
public Invocation(Object target, String methodName, Class[] parameterTypes) throws NoSuchMethodException
Constructor for an Invocation with arbitrary arguments in the target's method.- Parameters:
target-methodName-parameterTypes-- Throws:
NoSuchMethodException- ifmethodNamecould not be found in the targetIllegalArgumentException- if target or methodName arenull, or parameterTypes is empty or containsnullelements
-
-
Method Detail
-
fire
public boolean fire()
Invoke the target's method without any arguments.- See Also:
fire(Object[])
-
fire
public boolean fire(Object argument)
Invoke the target's method with a single argument.- Parameters:
argument- an object passed to the target's method- See Also:
fire(Object[])
-
fire
public boolean fire(Object[] arguments)
Invoke the target's method with an arbitrary number of arguments. The number of arguments must be consistent with the arguments given at construction time of this Invocation.- Parameters:
arguments- an array of objects passed to the target's method- Returns:
trueif invocation of the method succeeded, otherwisefalse.- Throws:
IllegalArgumentException- if the passed arguments are inconsistent with the arguments passed to this instance's constructor- See Also:
fire(Object[])
-
equals
public boolean equals(Object obj)
- Overrides:
equalsin classObject- See Also:
Object.equals(java.lang.Object)
-
hashCode
public int hashCode()
- Overrides:
hashCodein classObject- See Also:
Object.hashCode()
-
getMethod
public Method getMethod()
- Returns:
- the method to be invoked on the target
-
getTarget
public Object getTarget()
- Returns:
- the target object of this Invocation
-
getParameterTypes
public Class[] getParameterTypes()
- Returns:
- an array of Classes describing the target method's parameters
-
-