001 /* 002 * Copyright 2005 John G. Wilson 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * 016 */ 017 018 package groovy.lang; 019 020 import java.lang.reflect.Constructor; 021 import java.lang.reflect.Method; 022 import java.util.List; 023 import java.util.Map; 024 025 import org.codehaus.groovy.ast.ClassNode; 026 027 /** 028 * @author John Wilson 029 * 030 */ 031 032 public class DelegatingMetaClass extends MetaClass { 033 private final MetaClass delegate; 034 public DelegatingMetaClass(final MetaClass delegate) { 035 super(delegate.getClass()); 036 037 this.delegate = delegate; 038 } 039 /* (non-Javadoc) 040 * @see groovy.lang.MetaClass#addNewInstanceMethod(java.lang.reflect.Method) 041 */ 042 protected void addNewInstanceMethod(Method method) { 043 delegate.addNewInstanceMethod(method); 044 } 045 /* (non-Javadoc) 046 * @see groovy.lang.MetaClass#addNewStaticMethod(java.lang.reflect.Method) 047 */ 048 protected void addNewStaticMethod(Method method) { 049 delegate.addNewStaticMethod(method); 050 } 051 /* (non-Javadoc) 052 * @see groovy.lang.MetaClass#checkInitialised() 053 */ 054 protected void checkInitialised() { 055 delegate.checkInitialised(); 056 } 057 /* (non-Javadoc) 058 * @see groovy.lang.MetaClass#pickMethod(java.lang.Object, java.lang.String, java.lang.Object[]) 059 */ 060 protected MetaMethod pickMethod(Object object, String methodName, Object[] arguments) { 061 return delegate.pickMethod(object, methodName, arguments); 062 } 063 /* (non-Javadoc) 064 * @see groovy.lang.MetaClass#pickMethod(java.lang.String, java.lang.Class[]) 065 */ 066 protected MetaMethod pickMethod(String methodName, Class[] arguments) { 067 return delegate.pickMethod(methodName, arguments); 068 } 069 /* (non-Javadoc) 070 * @see groovy.lang.MetaClass#getAttribute(java.lang.Object, java.lang.String) 071 */ 072 public Object getAttribute(Object object, String attribute) { 073 return delegate.getAttribute(object, attribute); 074 } 075 /* (non-Javadoc) 076 * @see groovy.lang.MetaClass#getClassNode() 077 */ 078 public ClassNode getClassNode() { 079 return delegate.getClassNode(); 080 } 081 /* (non-Javadoc) 082 * @see groovy.lang.MetaClass#getMetaMethods() 083 */ 084 public List getMetaMethods() { 085 return delegate.getMetaMethods(); 086 } 087 /* (non-Javadoc) 088 * @see groovy.lang.MetaClass#getMethods() 089 */ 090 public List getMethods() { 091 return delegate.getMethods(); 092 } 093 /* (non-Javadoc) 094 * @see groovy.lang.MetaClass#getProperties() 095 */ 096 public List getProperties() { 097 return delegate.getProperties(); 098 } 099 /* (non-Javadoc) 100 * @see groovy.lang.MetaClass#getProperty(java.lang.Object, java.lang.String) 101 */ 102 public Object getProperty(Object object, String property) { 103 return delegate.getProperty(object, property); 104 } 105 /* (non-Javadoc) 106 * @see groovy.lang.MetaClass#invokeConstructor(java.lang.Object[]) 107 */ 108 public Object invokeConstructor(Object[] arguments) { 109 return delegate.invokeConstructor(arguments); 110 } 111 /* (non-Javadoc) 112 * @see groovy.lang.MetaClass#invokeConstructorAt(java.lang.Class, java.lang.Object[]) 113 */ 114 public Object invokeConstructorAt(Class at, Object[] arguments) { 115 return delegate.invokeConstructorAt(at, arguments); 116 } 117 /* (non-Javadoc) 118 * @see groovy.lang.MetaClass#invokeMethod(java.lang.Object, java.lang.String, java.lang.Object) 119 */ 120 public Object invokeMethod(Object object, String methodName, Object arguments) { 121 return delegate.invokeMethod(object, methodName, arguments); 122 } 123 /* (non-Javadoc) 124 * @see groovy.lang.MetaClass#invokeMethod(java.lang.Object, java.lang.String, java.lang.Object[]) 125 */ 126 public Object invokeMethod(Object object, String methodName, Object[] arguments) { 127 return delegate.invokeMethod(object, methodName, arguments); 128 } 129 /* (non-Javadoc) 130 * @see groovy.lang.MetaClass#invokeStaticMethod(java.lang.Object, java.lang.String, java.lang.Object[]) 131 */ 132 public Object invokeStaticMethod(Object object, String methodName, Object[] arguments) { 133 return delegate.invokeStaticMethod(object, methodName, arguments); 134 } 135 /* (non-Javadoc) 136 * @see groovy.lang.MetaClass#retrieveConstructor(java.lang.Class[]) 137 */ 138 public Constructor retrieveConstructor(Class[] arguments) { 139 return delegate.retrieveConstructor(arguments); 140 } 141 /* (non-Javadoc) 142 * @see groovy.lang.MetaClass#retrieveMethod(java.lang.Object, java.lang.String, java.lang.Object[]) 143 */ 144 public MetaMethod retrieveMethod(Object owner, String methodName, Object[] arguments) { 145 return delegate.retrieveMethod(owner, methodName, arguments); 146 } 147 /* (non-Javadoc) 148 * @see groovy.lang.MetaClass#retrieveMethod(java.lang.String, java.lang.Class[]) 149 */ 150 public MetaMethod retrieveMethod(String methodName, Class[] arguments) { 151 return delegate.retrieveMethod(methodName, arguments); 152 } 153 /* (non-Javadoc) 154 * @see groovy.lang.MetaClass#retrieveStaticMethod(java.lang.String, java.lang.Class[]) 155 */ 156 public MetaMethod retrieveStaticMethod(String methodName, Class[] arguments) { 157 return delegate.retrieveStaticMethod(methodName, arguments); 158 } 159 /* (non-Javadoc) 160 * @see groovy.lang.MetaClass#setAttribute(java.lang.Object, java.lang.String, java.lang.Object) 161 */ 162 public void setAttribute(Object object, String attribute, Object newValue) { 163 delegate.setAttribute(object, attribute, newValue); 164 } 165 /* (non-Javadoc) 166 * @see groovy.lang.MetaClass#setProperties(java.lang.Object, java.util.Map) 167 */ 168 public void setProperties(Object bean, Map map) { 169 delegate.setProperties(bean, map); 170 } 171 /* (non-Javadoc) 172 * @see groovy.lang.MetaClass#setProperty(java.lang.Object, java.lang.String, java.lang.Object) 173 */ 174 public void setProperty(Object object, String property, Object newValue) { 175 delegate.setProperty(object, property, newValue); 176 } 177 /* (non-Javadoc) 178 * @see java.lang.Object#equals(java.lang.Object) 179 */ 180 public boolean equals(Object obj) { 181 return delegate.equals(obj); 182 } 183 /* (non-Javadoc) 184 * @see java.lang.Object#hashCode() 185 */ 186 public int hashCode() { 187 return delegate.hashCode(); 188 } 189 /* (non-Javadoc) 190 * @see java.lang.Object#toString() 191 */ 192 public String toString() { 193 return delegate.toString(); 194 } 195 }