All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.sf.jagg.model.MethodCall Maven / Gradle / Ivy

Go to download

jAgg is a Java 5.0 API that supports “group by” operations on Lists of Java objects: aggregate operations such as count, sum, max, min, avg, and many more. It also allows custom aggregate operations.

The newest version!
package net.sf.jagg.model;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

import net.sf.jagg.model.ChainedMethodCall;

/**
 * A MethodCall bundles a Method object and an array
 * of parameter values together so they can go together into a Map
 * as the value.  This class existed as a private inner class of
 * MethodCache prior to version 0.5.0, but for 0.5.0, it was
 * pulled out and made public.  It was made to extend
 * ChainedMethodCall for version 0.8.0.
 *
 * @author Randy Gettman
 * @since 0.5.0
 */
public class MethodCall extends ChainedMethodCall
{
   private Method myMethod;
   private Object[] myParameters;

   /**
    * Constructs a MethodCall.
    * @param method The Method.
    * @param parameters The array of parameter values.
    */
   public MethodCall(Method method, Object[] parameters)
   {
      myMethod = method;
      myParameters = parameters;
   }

   /**
    * Returns the return type of the MethodCall.
    * @return A Class object representing the return type of the
    *    method.
    */
   public Class getReturnType()
   {
      return myMethod.getReturnType();
   }

   /**
    * Invokes the internal Method using the internal parameters,
    * and returns the result.
    * @param object The object on which to invoke the Method.
    * @return The result of the invocation on the Method.
    * @throws IllegalAccessException If the Method is inaccessible
    *    (private, etc.)
    * @throws InvocationTargetException If the Method throws an
    *    Exception during execution.
    */
   protected Object invokeMethod(Object object) throws IllegalAccessException, InvocationTargetException
   {
      return myMethod.invoke(object, myParameters);
   }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy