Top Description Fields Constructors Methods
org.junit.jupiter.params.converter

public abstract Class TypedArgumentConverter<S, T extends @Nullable Object>

extends Object
implements ArgumentConverter
Class Inheritance
All Implemented Interfaces
org.junit.jupiter.params.converter.ArgumentConverter
Annotations
@API
status:STABLE
since:5.10
Type Parameters
<S>
the type of the source argument to convert
<T>
the type of the target object to create from the source
Static Imports
org.apiguardian.api.API.Status.STABLE

TypedArgumentConverter is an abstract base class for ArgumentConverter implementations that always convert objects of a given source type into a given target type.
Since
5.7
See Also
ArgumentConverter, SimpleArgumentConverter

Field Summary

Modifier and TypeField and Description
private final Class<S>
private final Class<T>

Constructor Summary

AccessConstructor and Description
protected
TypedArgumentConverter(Class<S>
the type of the argument to convert; never null
sourceType
,
Class<@NonNull T>
the type of the target object to create from the source; never null
targetType
)

Create a new TypedArgumentConverter.

Method Summary

Modifier and TypeMethod and Description
public final @Nullable Object
public final @Nullable Object
private T
convert(@Nullable Object source, Class<?> actualTargetType)

protected abstract T

Returns:

the converted object; may be null but only if the target type is a reference type
convert
(@Nullable S
the source object to convert; may be null
source
)

Convert the supplied source object of type S into an object of type T.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

sourceTypeback to summary
private final Class<S> sourceType
targetTypeback to summary
private final Class<T> targetType

Constructor Detail

TypedArgumentConverterback to summary
protected TypedArgumentConverter(Class<S> sourceType, Class<@NonNull T> targetType)

Create a new TypedArgumentConverter.

Parameters
sourceType:Class<S>

the type of the argument to convert; never null

targetType:Class<@NonNull T>

the type of the target object to create from the source; never null

Method Detail

convertback to summary
public final @Nullable Object convert(@Nullable Object source, ParameterContext context) throws ArgumentConversionException
Annotations
@Override
convertback to summary
public final @Nullable Object convert(@Nullable Object source, FieldContext context) throws ArgumentConversionException
Annotations
@Override
convertback to summary
private T convert(@Nullable Object source, Class<?> actualTargetType)
convertback to summary
protected abstract T convert(@Nullable S source) throws ArgumentConversionException

Convert the supplied source object of type S into an object of type T.

Parameters
source:@Nullable S

the source object to convert; may be null

Returns:T

the converted object; may be null but only if the target type is a reference type

Exceptions
ArgumentConversionException:
if an error occurs during the conversion