001    package railo.runtime.reflection.pairs;
002    
003    import java.lang.reflect.InvocationTargetException;
004    import java.lang.reflect.Method;
005    
006    
007    /**
008     * class holds a Method and the parameter to call it
009     */
010    public final class MethodInstance {
011    
012            private Method method;
013            private Object[] args;
014    
015            /**
016             * constructor of the class
017             * @param method
018             * @param args
019             */
020            public MethodInstance(Method method, Object[] args) {
021                    this.method=method;
022                    this.args=args;
023                    method.setAccessible(true);
024            }
025            
026            /**
027             * Invokes the method
028             * @param o Object to invoke Method on it
029             * @return return value of the Method
030             * @throws IllegalAccessException
031             * @throws IllegalArgumentException
032             * @throws IllegalAccessException
033             * @throws InvocationTargetException
034             * @throws InvocationTargetException
035             */
036            public Object invoke(Object o) throws IllegalAccessException, InvocationTargetException {       
037                    return method.invoke(o,args);
038            }
039            
040        /**
041         * @return Returns the args.
042         */
043        public Object[] getArgs() {
044            return args;
045        }
046        /**
047         * @return Returns the method.
048         */
049        public Method getMethod() {
050            return method;
051        }
052    }