2 * Copyright 2004-2005 the original author or authors.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org
.codehaus
.groovy
.grails
.commons
.metaclass
;
18 * <p>Abstract class that provides default implementation for isArgumentsMatch
20 * @author Graeme Rocher
23 * Date Created: 9th June 2006
26 public abstract class AbstractDynamicConstructor
implements DynamicConstructor
{
28 private Class
[] argumentTypes
;
31 * Takes an array of types required to match this constructor
33 * @param argumentTypes The argument types
35 public AbstractDynamicConstructor(Class
[] argumentTypes
) {
36 this.argumentTypes
= argumentTypes
;
40 * @return True if the arguments types match those specified in the constructor
42 public boolean isArgumentsMatch(Object
[] args
) {
43 if(args
.length
!= argumentTypes
.length
)
46 for (int i
= 0; i
< args
.length
; i
++) {
47 if(!args
[i
].getClass().equals(argumentTypes
[i
]))
54 public abstract Object
invoke(Class clazz
, Object
[] args
);