Top Description Methods
org.junit.platform.commons.support.conversion

pack-priv Interface StringToObjectConverter

Known Direct Implementers
org.junit.platform.commons.support.conversion.FallbackStringToObjectConverter, org.junit.platform.commons.support.conversion.StringToBooleanConverter, org.junit.platform.commons.support.conversion.StringToCharacterConverter, org.junit.platform.commons.support.conversion.StringToClassConverter, org.junit.platform.commons.support.conversion.StringToCommonJavaTypesConverter, org.junit.platform.commons.support.conversion.StringToEnumConverter, org.junit.platform.commons.support.conversion.StringToJavaTimeConverter, org.junit.platform.commons.support.conversion.StringToNumberConverter
Imports
org.jspecify.annotations.Nullable

Internal API for converting arguments of type String to a specified target type.

Method Summary

Modifier and TypeMethod and Description
public boolean
canConvertTo(Class<?> targetType)

Determine if this converter can convert from a String to the supplied target type (which is guaranteed to be a wrapper type for primitives — for example, Integer instead of int).

public @Nullable Object
convert(String source, Class<?> targetType)

Convert the supplied String to the supplied target type (which is guaranteed to be a wrapper type for primitives — for example, Integer instead of int).

public default @Nullable Object
convert(String source, Class<?> targetType, ClassLoader classLoader)

Convert the supplied String to the supplied target type (which is guaranteed to be a wrapper type for primitives — for example, Integer instead of int).

Method Detail

canConvertToback to summary
public boolean canConvertTo(Class<?> targetType)

Determine if this converter can convert from a String to the supplied target type (which is guaranteed to be a wrapper type for primitives — for example, Integer instead of int).

convertback to summary
public @Nullable Object convert(String source, Class<?> targetType) throws Exception

Convert the supplied String to the supplied target type (which is guaranteed to be a wrapper type for primitives — for example, Integer instead of int).

This method will only be invoked if canConvertTo(Class) returns true for the same target type.

convertback to summary
public default @Nullable Object convert(String source, Class<?> targetType, ClassLoader classLoader) throws Exception

Convert the supplied String to the supplied target type (which is guaranteed to be a wrapper type for primitives — for example, Integer instead of int).

This method will only be invoked if canConvertTo(Class) returns true for the same target type.

The default implementation simply delegates to convert(String, Class). Can be overridden by concrete implementations of this interface that need access to the supplied ClassLoader.