@API(status=EXPERIMENTAL,
since="5.2")
public interface ArgumentsAccessor
ArgumentsAccessor defines the public API for accessing arguments provided
by an ArgumentsProvider
for a single invocation of a
@ParameterizedTest method.
Specifically, an ArgumentsAccessor aggregates a set of
arguments for a given invocation of a parameterized test and provides convenience
methods for accessing those arguments in a type-safe manner with support for
automatic type conversion.
An instance of ArgumentsAccessor will be automatically supplied
for any parameter of type ArgumentsAccessor in a parameterized test.
In addition, ArgumentsAggregator implementations are given access to
an ArgumentsAccessor.
This interface is not intended to be implemented by clients.
ArgumentsAggregator,
ParameterizedTest| Modifier and Type | Method and Description |
|---|---|
Object |
get(int index)
Get the value of the argument at the given index as an
Object. |
<T> T |
get(int index,
Class<T> requiredType)
Get the value of the argument at the given index as an instance of the
required type.
|
Boolean |
getBoolean(int index)
Get the value of the argument at the given index as a
Boolean,
performing automatic type conversion as necessary. |
Byte |
getByte(int index)
Get the value of the argument at the given index as a
Byte,
performing automatic type conversion as necessary. |
Character |
getCharacter(int index)
Get the value of the argument at the given index as a
Character,
performing automatic type conversion as necessary. |
Double |
getDouble(int index)
Get the value of the argument at the given index as a
Double,
performing automatic type conversion as necessary. |
Float |
getFloat(int index)
Get the value of the argument at the given index as a
Float,
performing automatic type conversion as necessary. |
Integer |
getInteger(int index)
Get the value of the argument at the given index as a
Integer,
performing automatic type conversion as necessary. |
Long |
getLong(int index)
Get the value of the argument at the given index as a
Long,
performing automatic type conversion as necessary. |
Short |
getShort(int index)
Get the value of the argument at the given index as a
Short,
performing automatic type conversion as necessary. |
String |
getString(int index)
Get the value of the argument at the given index as a
String,
performing automatic type conversion as necessary. |
int |
size()
Get the number of arguments in this accessor.
|
Object[] |
toArray()
Get all arguments in this accessor as an array.
|
List<Object> |
toList()
Get all arguments in this accessor as an immutable list.
|
Object get(int index) throws ArgumentAccessException
Object.index - the index of the argument to get; must be greater than or
equal to zero and less than size()nullArgumentAccessException<T> T get(int index,
Class<T> requiredType)
throws ArgumentAccessException
index - the index of the argument to get; must be greater than or
equal to zero and less than size()requiredType - the required type of the value; never nullnullArgumentAccessExceptionCharacter getCharacter(int index) throws ArgumentAccessException
Character,
performing automatic type conversion as necessary.index - the index of the argument to get; must be greater than or
equal to zero and less than size()nullArgumentAccessException - if the value cannot be accessed
or converted to the desired typeBoolean getBoolean(int index) throws ArgumentAccessException
Boolean,
performing automatic type conversion as necessary.index - the index of the argument to get; must be greater than or
equal to zero and less than size()nullArgumentAccessException - if the value cannot be accessed
or converted to the desired typeByte getByte(int index) throws ArgumentAccessException
Byte,
performing automatic type conversion as necessary.index - the index of the argument to get; must be greater than or
equal to zero and less than size()nullArgumentAccessException - if the value cannot be accessed
or converted to the desired typeShort getShort(int index) throws ArgumentAccessException
Short,
performing automatic type conversion as necessary.index - the index of the argument to get; must be greater than or
equal to zero and less than size()nullArgumentAccessException - if the value cannot be accessed
or converted to the desired typeInteger getInteger(int index) throws ArgumentAccessException
Integer,
performing automatic type conversion as necessary.index - the index of the argument to get; must be greater than or
equal to zero and less than size()nullArgumentAccessException - if the value cannot be accessed
or converted to the desired typeLong getLong(int index) throws ArgumentAccessException
Long,
performing automatic type conversion as necessary.index - the index of the argument to get; must be greater than or
equal to zero and less than size()nullArgumentAccessException - if the value cannot be accessed
or converted to the desired typeFloat getFloat(int index) throws ArgumentAccessException
Float,
performing automatic type conversion as necessary.index - the index of the argument to get; must be greater than or
equal to zero and less than size()nullArgumentAccessException - if the value cannot be accessed
or converted to the desired typeDouble getDouble(int index) throws ArgumentAccessException
Double,
performing automatic type conversion as necessary.index - the index of the argument to get; must be greater than or
equal to zero and less than size()nullArgumentAccessException - if the value cannot be accessed
or converted to the desired typeString getString(int index) throws ArgumentAccessException
String,
performing automatic type conversion as necessary.index - the index of the argument to get; must be greater than or
equal to zero and less than size()nullArgumentAccessException - if the value cannot be accessed
or converted to the desired typeint size()
Object[] toArray()
Copyright © 2020. All rights reserved.