Top Description Fields Constructors Methods
org.easymock

public Class Capture<T>

extends Object
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable
Type Parameters
<T>
Type of the captured element
Imports
java.io.Serializable, java.util.ArrayList, .List

Will contain what was captured by the capture() matcher. Knows if something was captured or not (allows to capture a null value).
Author
Henri Tremblay

Field Summary

Modifier and TypeField and Description
private static final long
private final CaptureType
private final List<T>

Constructor Summary

AccessConstructor and Description
private
Capture()

Default constructor.

private
Capture(CaptureType
capture type
type
)

Constructor allowing to select the capture type.

Method Summary

Modifier and TypeMethod and Description
public T

Returns:

The last captured value
getValue
()

Return captured value.

public List<T>

Returns:

The currently captured values
getValues
()

Return all captured values.

public boolean

Returns:

true if something was captured
hasCaptured
()

public static <
type of the class to be captured
T
>
Capture<T>

Returns:

the new capture object
newInstance
()

Create a new capture instance that will keep only the last captured value.

public static <
type of the class to be captured
T
>
Capture<T>

Returns:

the new capture object
newInstance
(CaptureType
capture type wanted
type
)

Create a new capture instance with a specific org.easymock.CaptureType.

public void
reset()

Will reset capture to a "nothing captured yet" state.

public void
setValue(T
Value captured
value
)

Used internally by the EasyMock framework to add a new captured value.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID
typeback to summary
private final CaptureType type
valuesback to summary
private final List<T> values

Constructor Detail

Captureback to summary
private Capture()

Default constructor. Only the last element will be captured

Captureback to summary
private Capture(CaptureType type)

Constructor allowing to select the capture type.

Parameters
type:CaptureType

capture type

Method Detail

getValueback to summary
public T getValue()

Return captured value.

Returns:T

The last captured value

Exceptions
AssertionError:
if nothing was captured yet or if more than one value was captured
getValuesback to summary
public List<T> getValues()

Return all captured values. It returns the actual list so you can modify it's content if needed.

Returns:List<T>

The currently captured values

hasCapturedback to summary
public boolean hasCaptured()
Returns:boolean

true if something was captured

newInstanceback to summary
public static <T> Capture<T> newInstance()

Create a new capture instance that will keep only the last captured value.

Parameters
<T>
type of the class to be captured
Returns:Capture<T>

the new capture object

newInstanceback to summary
public static <T> Capture<T> newInstance(CaptureType type)

Create a new capture instance with a specific org.easymock.CaptureType.

Parameters
<T>
type of the class to be captured
type:CaptureType

capture type wanted

Returns:Capture<T>

the new capture object

resetback to summary
public void reset()

Will reset capture to a "nothing captured yet" state.

setValueback to summary
public void setValue(T value)

Used internally by the EasyMock framework to add a new captured value.

Parameters
value:T

Value captured

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object

Annotations
@Override