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