Class DefaultArgumentsAccessor
java.lang.Object
org.junit.jupiter.params.aggregator.DefaultArgumentsAccessor
- All Implemented Interfaces:
ArgumentsAccessor
@API(status=INTERNAL,
since="5.2")
public class DefaultArgumentsAccessor
extends Object
implements ArgumentsAccessor
Default implementation of the
ArgumentsAccessor
API.
Delegates conversion to DefaultArgumentConverter
.
- Since:
- 5.2
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic DefaultArgumentsAccessor
create
(ExtensionContext context, int invocationIndex, ClassLoader classLoader, @Nullable Object[] arguments) @Nullable Object
get
(int index) Get the value of the argument at the given index as anObject
.<T> @Nullable T
Get the value of the argument at the given index as an instance of the required type.@Nullable Boolean
getBoolean
(int index) Get the value of the argument at the given index as aBoolean
, performing automatic type conversion as necessary.@Nullable Byte
getByte
(int index) Get the value of the argument at the given index as aByte
, performing automatic type conversion as necessary.@Nullable Character
getCharacter
(int index) Get the value of the argument at the given index as aCharacter
, performing automatic type conversion as necessary.@Nullable Double
getDouble
(int index) Get the value of the argument at the given index as aDouble
, performing automatic type conversion as necessary.@Nullable Float
getFloat
(int index) Get the value of the argument at the given index as aFloat
, performing automatic type conversion as necessary.@Nullable Integer
getInteger
(int index) Get the value of the argument at the given index as aInteger
, performing automatic type conversion as necessary.int
Get the index of the current test invocation.@Nullable Long
getLong
(int index) Get the value of the argument at the given index as aLong
, performing automatic type conversion as necessary.@Nullable Short
getShort
(int index) Get the value of the argument at the given index as aShort
, performing automatic type conversion as necessary.@Nullable String
getString
(int index) Get the value of the argument at the given index as aString
, performing automatic type conversion as necessary.int
size()
Get the number of arguments in this accessor.@Nullable Object[]
toArray()
Get all arguments in this accessor as an array.toList()
Get all arguments in this accessor as an immutable list.
-
Method Details
-
create
public static DefaultArgumentsAccessor create(ExtensionContext context, int invocationIndex, ClassLoader classLoader, @Nullable Object[] arguments) -
get
Description copied from interface:ArgumentsAccessor
Get the value of the argument at the given index as anObject
.- Specified by:
get
in interfaceArgumentsAccessor
- Parameters:
index
- the index of the argument to get; must be greater than or equal to zero and less thanArgumentsAccessor.size()
- Returns:
- the value at the given index, potentially
null
-
get
Description copied from interface:ArgumentsAccessor
Get the value of the argument at the given index as an instance of the required type.- Specified by:
get
in interfaceArgumentsAccessor
- Parameters:
index
- the index of the argument to get; must be greater than or equal to zero and less thanArgumentsAccessor.size()
requiredType
- the required type of the value; nevernull
- Returns:
- the value at the given index, potentially
null
-
getCharacter
Description copied from interface:ArgumentsAccessor
Get the value of the argument at the given index as aCharacter
, performing automatic type conversion as necessary.- Specified by:
getCharacter
in interfaceArgumentsAccessor
- Parameters:
index
- the index of the argument to get; must be greater than or equal to zero and less thanArgumentsAccessor.size()
- Returns:
- the value at the given index, potentially
null
-
getBoolean
Description copied from interface:ArgumentsAccessor
Get the value of the argument at the given index as aBoolean
, performing automatic type conversion as necessary.- Specified by:
getBoolean
in interfaceArgumentsAccessor
- Parameters:
index
- the index of the argument to get; must be greater than or equal to zero and less thanArgumentsAccessor.size()
- Returns:
- the value at the given index, potentially
null
-
getByte
Description copied from interface:ArgumentsAccessor
Get the value of the argument at the given index as aByte
, performing automatic type conversion as necessary.- Specified by:
getByte
in interfaceArgumentsAccessor
- Parameters:
index
- the index of the argument to get; must be greater than or equal to zero and less thanArgumentsAccessor.size()
- Returns:
- the value at the given index, potentially
null
-
getShort
Description copied from interface:ArgumentsAccessor
Get the value of the argument at the given index as aShort
, performing automatic type conversion as necessary.- Specified by:
getShort
in interfaceArgumentsAccessor
- Parameters:
index
- the index of the argument to get; must be greater than or equal to zero and less thanArgumentsAccessor.size()
- Returns:
- the value at the given index, potentially
null
-
getInteger
Description copied from interface:ArgumentsAccessor
Get the value of the argument at the given index as aInteger
, performing automatic type conversion as necessary.- Specified by:
getInteger
in interfaceArgumentsAccessor
- Parameters:
index
- the index of the argument to get; must be greater than or equal to zero and less thanArgumentsAccessor.size()
- Returns:
- the value at the given index, potentially
null
-
getLong
Description copied from interface:ArgumentsAccessor
Get the value of the argument at the given index as aLong
, performing automatic type conversion as necessary.- Specified by:
getLong
in interfaceArgumentsAccessor
- Parameters:
index
- the index of the argument to get; must be greater than or equal to zero and less thanArgumentsAccessor.size()
- Returns:
- the value at the given index, potentially
null
-
getFloat
Description copied from interface:ArgumentsAccessor
Get the value of the argument at the given index as aFloat
, performing automatic type conversion as necessary.- Specified by:
getFloat
in interfaceArgumentsAccessor
- Parameters:
index
- the index of the argument to get; must be greater than or equal to zero and less thanArgumentsAccessor.size()
- Returns:
- the value at the given index, potentially
null
-
getDouble
Description copied from interface:ArgumentsAccessor
Get the value of the argument at the given index as aDouble
, performing automatic type conversion as necessary.- Specified by:
getDouble
in interfaceArgumentsAccessor
- Parameters:
index
- the index of the argument to get; must be greater than or equal to zero and less thanArgumentsAccessor.size()
- Returns:
- the value at the given index, potentially
null
-
getString
Description copied from interface:ArgumentsAccessor
Get the value of the argument at the given index as aString
, performing automatic type conversion as necessary.- Specified by:
getString
in interfaceArgumentsAccessor
- Parameters:
index
- the index of the argument to get; must be greater than or equal to zero and less thanArgumentsAccessor.size()
- Returns:
- the value at the given index, potentially
null
-
size
public int size()Description copied from interface:ArgumentsAccessor
Get the number of arguments in this accessor.- Specified by:
size
in interfaceArgumentsAccessor
-
toArray
Description copied from interface:ArgumentsAccessor
Get all arguments in this accessor as an array.- Specified by:
toArray
in interfaceArgumentsAccessor
-
toList
Description copied from interface:ArgumentsAccessor
Get all arguments in this accessor as an immutable list.- Specified by:
toList
in interfaceArgumentsAccessor
-
getInvocationIndex
public int getInvocationIndex()Description copied from interface:ArgumentsAccessor
Get the index of the current test invocation.- Specified by:
getInvocationIndex
in interfaceArgumentsAccessor
-