Package org.jmock.lib
Class JavaReflectionImposteriser
- java.lang.Object
-
- org.jmock.lib.JavaReflectionImposteriser
-
- All Implemented Interfaces:
Imposteriser
public class JavaReflectionImposteriser extends java.lang.Object implements Imposteriser
AnImposteriser
that uses theProxy
class of the Java Reflection API.
-
-
Field Summary
Fields Modifier and Type Field Description static Imposteriser
INSTANCE
-
Constructor Summary
Constructors Constructor Description JavaReflectionImposteriser()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
canImposterise(java.lang.Class<?> type)
Reports if the Imposteriser is able to imposterise a given type.<T> T
imposterise(Invokable mockObject, java.lang.Class<T> mockedType, java.lang.Class<?>... ancilliaryTypes)
Creates an imposter for a given type that forwardsInvocation
s to anInvokable
object.private java.lang.Class<?>[]
prepend(java.lang.Class<?> first, java.lang.Class<?>... rest)
-
-
-
Field Detail
-
INSTANCE
public static final Imposteriser INSTANCE
-
-
Method Detail
-
canImposterise
public boolean canImposterise(java.lang.Class<?> type)
Description copied from interface:Imposteriser
Reports if the Imposteriser is able to imposterise a given type.- Specified by:
canImposterise
in interfaceImposteriser
- Parameters:
type
- The type in question.- Returns:
- True if this imposteriser can imposterise type, false otherwise.
-
imposterise
public <T> T imposterise(Invokable mockObject, java.lang.Class<T> mockedType, java.lang.Class<?>... ancilliaryTypes)
Description copied from interface:Imposteriser
Creates an imposter for a given type that forwardsInvocation
s to anInvokable
object.- Specified by:
imposterise
in interfaceImposteriser
- Type Parameters:
T
- The static type of the imposter that is created.- Parameters:
mockObject
- The object that is to receive invocations forwarded from the imposter.mockedType
- The class representing the static type of the imposter.ancilliaryTypes
- Other types for the imposter. It must be possible to dynamically cast the imposter to these types. These types must all be interfaces because Java only allows single inheritance of classes.- Returns:
- A new imposter. The imposter must implement the mockedType and all the ancialliaryTypes.
-
prepend
private java.lang.Class<?>[] prepend(java.lang.Class<?> first, java.lang.Class<?>... rest)
-
-