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 Type
    Method
    Description
    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 an Object.
    <T> @Nullable T
    get(int index, Class<T> requiredType)
    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 a Boolean, performing automatic type conversion as necessary.
    @Nullable Byte
    getByte(int index)
    Get the value of the argument at the given index as a Byte, performing automatic type conversion as necessary.
    @Nullable Character
    getCharacter(int index)
    Get the value of the argument at the given index as a Character, performing automatic type conversion as necessary.
    @Nullable Double
    getDouble(int index)
    Get the value of the argument at the given index as a Double, performing automatic type conversion as necessary.
    @Nullable Float
    getFloat(int index)
    Get the value of the argument at the given index as a Float, performing automatic type conversion as necessary.
    @Nullable Integer
    getInteger(int index)
    Get the value of the argument at the given index as a Integer, 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 a Long, performing automatic type conversion as necessary.
    @Nullable Short
    getShort(int index)
    Get the value of the argument at the given index as a Short, performing automatic type conversion as necessary.
    @Nullable String
    getString(int index)
    Get the value of the argument at the given index as a String, performing automatic type conversion as necessary.
    int
    Get the number of arguments in this accessor.
    @Nullable Object[]
    Get all arguments in this accessor as an array.
    List<@Nullable Object>
    Get all arguments in this accessor as an immutable list.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • create

      public static DefaultArgumentsAccessor create(ExtensionContext context, int invocationIndex, ClassLoader classLoader, @Nullable Object[] arguments)
    • get

      public @Nullable Object get(int index)
      Description copied from interface: ArgumentsAccessor
      Get the value of the argument at the given index as an Object.
      Specified by:
      get in interface ArgumentsAccessor
      Parameters:
      index - the index of the argument to get; must be greater than or equal to zero and less than ArgumentsAccessor.size()
      Returns:
      the value at the given index, potentially null
    • get

      public <T> @Nullable T get(int index, Class<T> requiredType)
      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 interface ArgumentsAccessor
      Parameters:
      index - the index of the argument to get; must be greater than or equal to zero and less than ArgumentsAccessor.size()
      requiredType - the required type of the value; never null
      Returns:
      the value at the given index, potentially null
    • getCharacter

      public @Nullable Character getCharacter(int index)
      Description copied from interface: ArgumentsAccessor
      Get the value of the argument at the given index as a Character, performing automatic type conversion as necessary.
      Specified by:
      getCharacter in interface ArgumentsAccessor
      Parameters:
      index - the index of the argument to get; must be greater than or equal to zero and less than ArgumentsAccessor.size()
      Returns:
      the value at the given index, potentially null
    • getBoolean

      public @Nullable Boolean getBoolean(int index)
      Description copied from interface: ArgumentsAccessor
      Get the value of the argument at the given index as a Boolean, performing automatic type conversion as necessary.
      Specified by:
      getBoolean in interface ArgumentsAccessor
      Parameters:
      index - the index of the argument to get; must be greater than or equal to zero and less than ArgumentsAccessor.size()
      Returns:
      the value at the given index, potentially null
    • getByte

      public @Nullable Byte getByte(int index)
      Description copied from interface: ArgumentsAccessor
      Get the value of the argument at the given index as a Byte, performing automatic type conversion as necessary.
      Specified by:
      getByte in interface ArgumentsAccessor
      Parameters:
      index - the index of the argument to get; must be greater than or equal to zero and less than ArgumentsAccessor.size()
      Returns:
      the value at the given index, potentially null
    • getShort

      public @Nullable Short getShort(int index)
      Description copied from interface: ArgumentsAccessor
      Get the value of the argument at the given index as a Short, performing automatic type conversion as necessary.
      Specified by:
      getShort in interface ArgumentsAccessor
      Parameters:
      index - the index of the argument to get; must be greater than or equal to zero and less than ArgumentsAccessor.size()
      Returns:
      the value at the given index, potentially null
    • getInteger

      public @Nullable Integer getInteger(int index)
      Description copied from interface: ArgumentsAccessor
      Get the value of the argument at the given index as a Integer, performing automatic type conversion as necessary.
      Specified by:
      getInteger in interface ArgumentsAccessor
      Parameters:
      index - the index of the argument to get; must be greater than or equal to zero and less than ArgumentsAccessor.size()
      Returns:
      the value at the given index, potentially null
    • getLong

      public @Nullable Long getLong(int index)
      Description copied from interface: ArgumentsAccessor
      Get the value of the argument at the given index as a Long, performing automatic type conversion as necessary.
      Specified by:
      getLong in interface ArgumentsAccessor
      Parameters:
      index - the index of the argument to get; must be greater than or equal to zero and less than ArgumentsAccessor.size()
      Returns:
      the value at the given index, potentially null
    • getFloat

      public @Nullable Float getFloat(int index)
      Description copied from interface: ArgumentsAccessor
      Get the value of the argument at the given index as a Float, performing automatic type conversion as necessary.
      Specified by:
      getFloat in interface ArgumentsAccessor
      Parameters:
      index - the index of the argument to get; must be greater than or equal to zero and less than ArgumentsAccessor.size()
      Returns:
      the value at the given index, potentially null
    • getDouble

      public @Nullable Double getDouble(int index)
      Description copied from interface: ArgumentsAccessor
      Get the value of the argument at the given index as a Double, performing automatic type conversion as necessary.
      Specified by:
      getDouble in interface ArgumentsAccessor
      Parameters:
      index - the index of the argument to get; must be greater than or equal to zero and less than ArgumentsAccessor.size()
      Returns:
      the value at the given index, potentially null
    • getString

      public @Nullable String getString(int index)
      Description copied from interface: ArgumentsAccessor
      Get the value of the argument at the given index as a String, performing automatic type conversion as necessary.
      Specified by:
      getString in interface ArgumentsAccessor
      Parameters:
      index - the index of the argument to get; must be greater than or equal to zero and less than ArgumentsAccessor.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 interface ArgumentsAccessor
    • toArray

      public @Nullable Object[] toArray()
      Description copied from interface: ArgumentsAccessor
      Get all arguments in this accessor as an array.
      Specified by:
      toArray in interface ArgumentsAccessor
    • toList

      public List<@Nullable Object> toList()
      Description copied from interface: ArgumentsAccessor
      Get all arguments in this accessor as an immutable list.
      Specified by:
      toList in interface ArgumentsAccessor
    • getInvocationIndex

      public int getInvocationIndex()
      Description copied from interface: ArgumentsAccessor
      Get the index of the current test invocation.
      Specified by:
      getInvocationIndex in interface ArgumentsAccessor