Package groovy.mock.interceptor
Class MockProxyMetaClass
- java.lang.Object
-
- groovy.lang.MetaClassImpl
-
- groovy.lang.ProxyMetaClass
-
- groovy.mock.interceptor.MockProxyMetaClass
-
- All Implemented Interfaces:
AdaptingMetaClass,MetaClass,MetaObjectProtocol,MutableMetaClass
public class MockProxyMetaClass extends ProxyMetaClass
The ProxyMetaClass for the MockInterceptor. Instance and class methods are intercepted, but constructors are not to allow mocking of aggregated objects.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class groovy.lang.MetaClassImpl
MetaClassImpl.Index, MetaClassImpl.MetaConstructor
-
-
Field Summary
Fields Modifier and Type Field Description booleaninterceptConstruction-
Fields inherited from class groovy.lang.ProxyMetaClass
adaptee, interceptor
-
Fields inherited from class groovy.lang.MetaClassImpl
EMPTY_ARGUMENTS, getPropertyMethod, INVOKE_METHOD_METHOD, invokeMethodMethod, isGroovyObject, isMap, metaMethodIndex, METHOD_MISSING, PROPERTY_MISSING, registry, setPropertyMethod, STATIC_METHOD_MISSING, STATIC_PROPERTY_MISSING, theCachedClass, theClass
-
-
Constructor Summary
Constructors Constructor Description MockProxyMetaClass(MetaClassRegistry registry, java.lang.Class theClass, MetaClass adaptee)MockProxyMetaClass(MetaClassRegistry registry, java.lang.Class theClass, MetaClass adaptee, boolean interceptConstruction)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.ObjectgetProperty(java.lang.Class aClass, java.lang.Object object, java.lang.String property, boolean b, boolean b1)Interceptors the call to getProperty if a PropertyAccessInterceptor is availablejava.lang.ObjectinvokeConstructor(java.lang.Object[] arguments)Unlike general impl in superclass, ctors are not intercepted but relayed unless interceptConstruction is set.java.lang.ObjectinvokeMethod(java.lang.Object object, java.lang.String methodName, java.lang.Object[] arguments)Call invokeMethod on adaptee with logic like in MetaClass unless we have an Interceptor.java.lang.ObjectinvokeStaticMethod(java.lang.Object object, java.lang.String methodName, java.lang.Object[] arguments)Call invokeStaticMethod on adaptee with logic like in MetaClass unless we have an Interceptor.static MockProxyMetaClassmake(java.lang.Class theClass)convenience factory method for the most usual case.static MockProxyMetaClassmake(java.lang.Class theClass, boolean interceptConstruction)convenience factory method allowing interceptConstruction to be set.voidsetProperty(java.lang.Class aClass, java.lang.Object object, java.lang.String property, java.lang.Object newValue, boolean b, boolean b1)Interceptors the call to a property setter if a PropertyAccessInterceptor is available-
Methods inherited from class groovy.lang.ProxyMetaClass
getAdaptee, getInstance, getInterceptor, initialize, invokeMethod, setAdaptee, setInterceptor, use, use
-
Methods inherited from class groovy.lang.MetaClassImpl
addMetaBeanProperty, addMetaMethod, addMetaMethodToIndex, addNewInstanceMethod, addNewStaticMethod, applyPropertyDescriptors, checkIfGroovyObjectMethod, checkInitalised, chooseMethod, clearInvocationCaches, createConstructorSite, createErrorMessageForAmbiguity, createPogoCallCurrentSite, createPogoCallSite, createPojoCallSite, createStaticSite, createTransformMetaMethod, doChooseMostSpecificParams, dropMethodCache, dropStaticMethodCache, findMethodInClassHierarchy, findMixinMethod, findOwnMethod, findPropertyInClassHierarchy, getAdditionalMetaMethods, getAttribute, getAttribute, getAttribute, getClassInfo, getClassNode, getEffectiveGetMetaProperty, getMetaMethod, getMetaMethods, getMetaProperty, getMethods, getMethodWithCaching, getMethodWithoutCaching, getProperties, getProperty, getRegistry, getStaticMetaMethod, getSubclassMetaMethods, getSuperClasses, getTheCachedClass, getTheClass, getVersion, handleMatches, hasCustomInvokeMethod, hasCustomStaticInvokeMethod, hasProperty, incVersion, invokeMethod, invokeMissingMethod, invokeMissingProperty, invokeStaticMissingProperty, isGroovyObject, isInitialized, isModified, onGetPropertyFoundInHierarchy, onInvokeMethodFoundInHierarchy, onMixinMethodFound, onSetPropertyFoundInHierarchy, onSuperMethodFoundInHierarchy, onSuperPropertyFoundInHierarchy, pickMethod, respondsTo, respondsTo, retrieveConstructor, retrieveConstructor, retrieveStaticMethod, selectConstructorAndTransformArguments, setAttribute, setAttribute, setInitialized, setProperties, setProperty, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface groovy.lang.MetaClass
getAttribute, getClassNode, getMetaMethods, getMethods, getProperties, invokeMissingMethod, invokeMissingProperty, pickMethod, selectConstructorAndTransformArguments, setAttribute
-
Methods inherited from interface groovy.lang.MetaObjectProtocol
getAttribute, getMetaMethod, getMetaProperty, getProperty, getStaticMetaMethod, getTheClass, hasProperty, invokeMethod, respondsTo, respondsTo, setAttribute, setProperty
-
-
-
-
Constructor Detail
-
MockProxyMetaClass
public MockProxyMetaClass(MetaClassRegistry registry, java.lang.Class theClass, MetaClass adaptee)
- Parameters:
adaptee- the MetaClass to decorate with interceptability
-
MockProxyMetaClass
public MockProxyMetaClass(MetaClassRegistry registry, java.lang.Class theClass, MetaClass adaptee, boolean interceptConstruction)
- Parameters:
adaptee- the MetaClass to decorate with interceptability
-
-
Method Detail
-
make
public static MockProxyMetaClass make(java.lang.Class theClass)
convenience factory method for the most usual case.
-
make
public static MockProxyMetaClass make(java.lang.Class theClass, boolean interceptConstruction)
convenience factory method allowing interceptConstruction to be set.
-
invokeMethod
public java.lang.Object invokeMethod(java.lang.Object object, java.lang.String methodName, java.lang.Object[] arguments)Description copied from class:ProxyMetaClassCall invokeMethod on adaptee with logic like in MetaClass unless we have an Interceptor. With Interceptor the call is nested in its beforeInvoke and afterInvoke methods. The method call is suppressed if Interceptor.doInvoke() returns false. See Interceptor for details.- Specified by:
invokeMethodin interfaceMetaObjectProtocol- Overrides:
invokeMethodin classProxyMetaClass- Parameters:
object- The object which the method was invoked onmethodName- The name of the methodarguments- The arguments to the method- Returns:
- The return value of the method
- See Also:
MetaClass.invokeMethod(Class, Object, String, Object[], boolean, boolean)
-
invokeStaticMethod
public java.lang.Object invokeStaticMethod(java.lang.Object object, java.lang.String methodName, java.lang.Object[] arguments)Description copied from class:ProxyMetaClassCall invokeStaticMethod on adaptee with logic like in MetaClass unless we have an Interceptor. With Interceptor the call is nested in its beforeInvoke and afterInvoke methods. The method call is suppressed if Interceptor.doInvoke() returns false. See Interceptor for details.- Specified by:
invokeStaticMethodin interfaceMetaObjectProtocol- Overrides:
invokeStaticMethodin classProxyMetaClass- Parameters:
object- An instance of the class returned by the getTheClass() method or the class itselfmethodName- The name of the methodarguments- The arguments to the method- Returns:
- The return value of the method which is null if the return type is void
- See Also:
MissingMethodException
-
getProperty
public java.lang.Object getProperty(java.lang.Class aClass, java.lang.Object object, java.lang.String property, boolean b, boolean b1)Description copied from class:ProxyMetaClassInterceptors the call to getProperty if a PropertyAccessInterceptor is available- Specified by:
getPropertyin interfaceMetaClass- Overrides:
getPropertyin classProxyMetaClass- Parameters:
aClass- The java.lang.Class instance that requested the propertyobject- the object to invoke the getter onproperty- the property nameb- Whether the call is to a super class propertyb1- ??- Returns:
- the value of the property
-
setProperty
public void setProperty(java.lang.Class aClass, java.lang.Object object, java.lang.String property, java.lang.Object newValue, boolean b, boolean b1)Description copied from class:ProxyMetaClassInterceptors the call to a property setter if a PropertyAccessInterceptor is available- Specified by:
setPropertyin interfaceMetaClass- Overrides:
setPropertyin classProxyMetaClass- Parameters:
aClass- The java.lang.Class instance that is mutating the propertyobject- The object to invoke the setter onproperty- The property name to setnewValue- The new value of the propertyb- Whether the call is to a super class propertyb1- Whether the call was invoked from the inside or the outside of the class.
-
invokeConstructor
public java.lang.Object invokeConstructor(java.lang.Object[] arguments)
Unlike general impl in superclass, ctors are not intercepted but relayed unless interceptConstruction is set.- Specified by:
invokeConstructorin interfaceMetaObjectProtocol- Overrides:
invokeConstructorin classProxyMetaClass- Parameters:
arguments- The arguments to the constructor- Returns:
- An instance of the java.lang.Class that this MetaObjectProtocol object applies to
-
-