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
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.MetaConstructor -
Field Summary
FieldsModifier and TypeFieldDescriptionfinal booleanIndicates whether constructor invocations should be intercepted.Fields inherited from class groovy.lang.ProxyMetaClass
adaptee, interceptorFields 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
ConstructorsConstructorDescriptionMockProxyMetaClass(MetaClassRegistry registry, Class theClass, MetaClass adaptee) MockProxyMetaClass(MetaClassRegistry registry, Class theClass, MetaClass adaptee, boolean interceptConstruction) -
Method Summary
Modifier and TypeMethodDescriptiongetProperty(Class aClass, Object object, String property, boolean b, boolean b1) Intercepts a property read and delegates to the adaptee when no custom value is supplied.invokeConstructor(Object[] arguments) Intercepts or delegates constructor invocation depending oninterceptConstruction.invokeMethod(Class sender, Object object, String methodName, Object[] arguments, boolean isCallToSuper, boolean fromInsideClass) Intercepts an instance method invocation with sender metadata and delegates when requested.invokeMethod(Object object, String methodName, Object[] arguments) Intercepts an instance method invocation and delegates to the adaptee when requested.invokeStaticMethod(Object object, String methodName, Object[] arguments) Intercepts a static method invocation and delegates to the adaptee when requested.static MockProxyMetaClassconvenience factory method for the most usual case.static MockProxyMetaClassconvenience factory method allowing interceptConstruction to be set.voidsetProperty(Class aClass, Object object, String property, Object newValue, boolean b, boolean b1) Intercepts a property write and delegates to the adaptee when no custom handling is supplied.Methods inherited from class groovy.lang.ProxyMetaClass
getAdaptee, getInstance, getInterceptor, initialize, setAdaptee, setInterceptor, use, useMethods 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, getNonClosureOuter, getProperties, getProperty, getRegistry, getStaticMetaMethod, getSubclassMetaMethods, getSuperClasses, getTheCachedClass, getTheClass, getVersion, handleMatches, hasCustomInvokeMethod, hasCustomStaticInvokeMethod, hasProperty, incVersion, invokeMethod, invokeMissingMethod, invokeMissingProperty, invokeStaticMissingProperty, isGroovyObject, isInitialized, isModified, isPermissivePropertyAccess, onGetPropertyFoundInHierarchy, onInvokeMethodFoundInHierarchy, onMixinMethodFound, onSetPropertyFoundInHierarchy, onSuperMethodFoundInHierarchy, onSuperPropertyFoundInHierarchy, pickMethod, reinitialize, respondsTo, respondsTo, retrieveConstructor, retrieveConstructor, retrieveStaticMethod, selectConstructorAndTransformArguments, setAttribute, setAttribute, setInitialized, setPermissivePropertyAccess, setProperties, setProperty, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface groovy.lang.MetaClass
getAttribute, getClassNode, getMetaMethods, getMethods, getProperties, invokeMissingMethod, invokeMissingProperty, pickMethod, selectConstructorAndTransformArguments, setAttributeMethods inherited from interface groovy.lang.MetaObjectProtocol
getAttribute, getMetaMethod, getMetaProperty, getProperty, getStaticMetaMethod, getTheClass, hasProperty, invokeMethod, respondsTo, respondsTo, setAttribute, setProperty
-
Field Details
-
interceptConstruction
public final boolean interceptConstructionIndicates whether constructor invocations should be intercepted.
-
-
Constructor Details
-
MockProxyMetaClass
- Parameters:
adaptee- the MetaClass to decorate with interceptability
-
MockProxyMetaClass
public MockProxyMetaClass(MetaClassRegistry registry, Class theClass, MetaClass adaptee, boolean interceptConstruction) - Parameters:
adaptee- the MetaClass to decorate with interceptability
-
-
Method Details
-
make
convenience factory method for the most usual case. -
make
convenience factory method allowing interceptConstruction to be set. -
invokeMethod
Intercepts an instance method invocation and delegates to the adaptee when requested.- Specified by:
invokeMethodin interfaceMetaObjectProtocol- Overrides:
invokeMethodin classProxyMetaClass- Parameters:
object- the receiver of the method callmethodName- the method namearguments- the invocation arguments- Returns:
- the interceptor result or the adaptee result when falling through
- See Also:
-
invokeMethod
public Object invokeMethod(Class sender, Object object, String methodName, Object[] arguments, boolean isCallToSuper, boolean fromInsideClass) Intercepts an instance method invocation with sender metadata and delegates when requested.- Specified by:
invokeMethodin interfaceMetaClass- Overrides:
invokeMethodin classProxyMetaClass- Parameters:
sender- the sender classobject- the receiver of the method callmethodName- the method namearguments- the invocation argumentsisCallToSuper- whether the call targets a superclass implementationfromInsideClass- whether the call originates from inside the declaring class- Returns:
- the interceptor result or the adaptee result when falling through
- See Also:
-
invokeStaticMethod
Intercepts a static method invocation and delegates to the adaptee when requested.- Specified by:
invokeStaticMethodin interfaceMetaObjectProtocol- Overrides:
invokeStaticMethodin classProxyMetaClass- Parameters:
object- the static receivermethodName- the method namearguments- the invocation arguments- Returns:
- the interceptor result or the adaptee result when falling through
- See Also:
-
getProperty
Intercepts a property read and delegates to the adaptee when no custom value is supplied.- Specified by:
getPropertyin interfaceMetaClass- Overrides:
getPropertyin classProxyMetaClass- Parameters:
aClass- the dispatch classobject- the receiver of the property accessproperty- the property nameb- implementation-specific flag forwarded to the adapteeb1- implementation-specific flag forwarded to the adaptee- Returns:
- the intercepted or delegated property value
-
setProperty
public void setProperty(Class aClass, Object object, String property, Object newValue, boolean b, boolean b1) Intercepts a property write and delegates to the adaptee when no custom handling is supplied.- Specified by:
setPropertyin interfaceMetaClass- Overrides:
setPropertyin classProxyMetaClass- Parameters:
aClass- the dispatch classobject- the receiver of the property accessproperty- the property namenewValue- the value to assignb- implementation-specific flag forwarded to the adapteeb1- implementation-specific flag forwarded to the adaptee
-
invokeConstructor
Intercepts or delegates constructor invocation depending oninterceptConstruction.- Specified by:
invokeConstructorin interfaceMetaObjectProtocol- Overrides:
invokeConstructorin classProxyMetaClass- Parameters:
arguments- the constructor arguments- Returns:
- the constructed instance or interceptor-supplied replacement
-