001/** 002 * 003 * Copyright (c) 2014, the Railo Company Ltd. All rights reserved. 004 * 005 * This library is free software; you can redistribute it and/or 006 * modify it under the terms of the GNU Lesser General Public 007 * License as published by the Free Software Foundation; either 008 * version 2.1 of the License, or (at your option) any later version. 009 * 010 * This library is distributed in the hope that it will be useful, 011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 013 * Lesser General Public License for more details. 014 * 015 * You should have received a copy of the GNU Lesser General Public 016 * License along with this library. If not, see <http://www.gnu.org/licenses/>. 017 * 018 **/ 019package lucee.runtime.reflection.pairs; 020 021import java.lang.reflect.InvocationTargetException; 022import java.lang.reflect.Method; 023 024 025/** 026 * class holds a Method and the parameter to call it 027 */ 028public final class MethodInstance { 029 030 private Method method; 031 private Object[] args; 032 033 /** 034 * constructor of the class 035 * @param method 036 * @param args 037 */ 038 public MethodInstance(Method method, Object[] args) { 039 this.method=method; 040 this.args=args; 041 method.setAccessible(true); 042 } 043 044 /** 045 * Invokes the method 046 * @param o Object to invoke Method on it 047 * @return return value of the Method 048 * @throws IllegalAccessException 049 * @throws IllegalArgumentException 050 * @throws IllegalAccessException 051 * @throws InvocationTargetException 052 * @throws InvocationTargetException 053 */ 054 public Object invoke(Object o) throws IllegalAccessException, InvocationTargetException { 055 return method.invoke(o,args); 056 } 057 058 /** 059 * @return Returns the args. 060 */ 061 public Object[] getArgs() { 062 return args; 063 } 064 /** 065 * @return Returns the method. 066 */ 067 public Method getMethod() { 068 return method; 069 } 070}