T - Type of the captured elementpublic class Capture<T> extends Object implements Serializable
capture() matcher. Knows
if something was captured or not (allows to capture a null value).
Implementation note:
If the capture is serialized, it is the user duty to make sure the transformation used also is serializable.| Modifier and Type | Method and Description |
|---|---|
T |
getValue()
Return captured value.
|
List<T> |
getValues()
Return all captured values.
|
boolean |
hasCaptured() |
static <T> Capture<T> |
newInstance()
Create a new capture instance that will keep only the last captured value.
|
static <T> Capture<T> |
newInstance(CaptureType type)
Create a new capture instance with a specific
CaptureType. |
static <T> Capture<T> |
newInstance(CaptureType type,
UnaryOperator<T> transform)
Create a new capture instance with a specific
CaptureType
and a specific transformation function to change the values
into a different value. |
static <T> Capture<T> |
newInstance(UnaryOperator<T> transform)
Create a new capture instance with a specific transformation
function to change the values into a different value.
|
void |
reset()
Will reset capture to a "nothing captured yet" state
|
void |
setValue(T value)
Used internally by the EasyMock framework to add a new captured value.
|
String |
toString() |
public static <T> Capture<T> newInstance()
T - type of the class to be capturedpublic static <T> Capture<T> newInstance(CaptureType type)
CaptureType.T - type of the class to be capturedtype - capture type wantedpublic static <T> Capture<T> newInstance(CaptureType type, UnaryOperator<T> transform)
CaptureType
and a specific transformation function to change the values
into a different value.T - type of the class to be capturedtype - capture type wantedtransform - the transform functionpublic static <T> Capture<T> newInstance(UnaryOperator<T> transform)
T - type of the class to be capturedtransform - the transform functionpublic void reset()
public boolean hasCaptured()
public T getValue()
AssertionError - if nothing was captured yet or if more than one value was
capturedpublic List<T> getValues()
public void setValue(T value)
value - Value capturedCopyright © 2001–2024 EasyMock contributors. All rights reserved.