Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.mockito.internal.stubbing.answers
Class ReturnsArgumentAt

    java.lang.Object
      org.mockito.internal.stubbing.answers.ReturnsArgumentAt

All Implemented Interfaces:
  java.io.Serializable, Answer<java.lang.Object>

    public class ReturnsArgumentAt

extends java.lang.Object
implements Answer<java.lang.Object>, java.io.Serializable

Returns the passed parameter identity at specified index.

The `argumentIndex` represents the index in the argument array of the invocation.

If this number equals -1 then the last argument is returned.

Since:
  1.9.5
See Also:
  `AdditionalAnswers`, Serialized Form

Field Summary
`static int` | `LAST_ARGUMENT`

Constructor Summary
`ReturnsArgumentAt(int wantedArgumentPosition)` Build the identity answer to return the argument at the given position in the argument array.

Method Summary
`java.lang.Object` | `answer(InvocationOnMock invocation)`
`java.lang.Class` | `returnedTypeOnSignature(InvocationOnMock invocation)`
`void` | `validateIndexWithinInvocationRange(InvocationOnMock invocation)`
`int` | `wantedArgumentPosition()`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### LAST_ARGUMENT

    public static final int LAST_ARGUMENT

See Also:
  Constant Field Values

Constructor Detail

### ReturnsArgumentAt

    public ReturnsArgumentAt(int wantedArgumentPosition)

  Build the identity answer to return the argument at the given position in the argument array.

  Parameters:
    `wantedArgumentPosition` - The position of the argument identity to return in the invocation. Using `-1` indicates the last argument.

Method Detail

### answer

    public java.lang.Object answer(InvocationOnMock invocation)
                            throws java.lang.Throwable

  Specified by:
    `answer` in interface `Answer<java.lang.Object>`
  Parameters:
    `invocation` - the invocation on the mock.
  Returns:
    the value to be returned
  Throws:
    `java.lang.Throwable` - the throwable to be thrown

### wantedArgumentPosition

    public int wantedArgumentPosition()

### validateIndexWithinInvocationRange

    public void validateIndexWithinInvocationRange(InvocationOnMock invocation)

### returnedTypeOnSignature

    public java.lang.Class returnedTypeOnSignature(InvocationOnMock invocation)

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD