GRAILS-1019: Allowing expressions to be used with the 'disabled' attribute for g...
[grails.git] / src / commons / org / codehaus / groovy / grails / commons / metaclass / AbstractDynamicConstructor.java
blobb97b79233681ae3217b0b50bcd6dcc6260632dc2
1 /*
2 * Copyright 2004-2005 the original author or authors.
3 *
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
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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;
17 /**
18 * <p>Abstract class that provides default implementation for isArgumentsMatch
20 * @author Graeme Rocher
21 * @since 0.2
23 * Date Created: 9th June 2006
26 public abstract class AbstractDynamicConstructor implements DynamicConstructor {
28 private Class[] argumentTypes;
30 /**
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;
39 /**
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)
44 return false;
45 else {
46 for (int i = 0; i < args.length; i++) {
47 if(!args[i].getClass().equals(argumentTypes[i]))
48 return false;
51 return true;
54 public abstract Object invoke(Class clazz, Object[] args);