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.Constructor; 022import java.lang.reflect.InvocationTargetException; 023 024 025/** 026 * class holds a Constructor and the parameter to call it 027 */ 028public final class ConstructorInstance { 029 030 private Constructor constructor; 031 private Object[] args; 032 033 /** 034 * constructor of the class 035 * @param constructor 036 * @param args 037 */ 038 public ConstructorInstance(Constructor constructor, Object[] args) { 039 this.constructor=constructor; 040 this.args=args; 041 } 042 043 /** 044 * Invokes the method 045 * @return return value of the Method 046 * @throws InvocationTargetException 047 * @throws IllegalAccessException 048 * @throws InstantiationException 049 * @throws IllegalArgumentException 050 */ 051 public Object invoke() throws IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException { 052 return constructor.newInstance(args); 053 } 054 055 /** 056 * @return Returns the args. 057 */ 058 public Object[] getArgs() { 059 return args; 060 } 061 /** 062 * @return Returns the constructor. 063 */ 064 public Constructor getConstructor() { 065 return constructor; 066 } 067}