public interface ConversionService
convert(Object, Class)
を呼び出して、このシステムを使用してスレッドセーフな型変換を実行します。修飾子と型 | メソッドと説明 |
---|---|
boolean | canConvert(ClassSE<?> sourceType, ClassSE<?> targetType) sourceType のオブジェクトを targetType に変換できる場合は、true を返します。 |
boolean | canConvert(TypeDescriptor sourceType, TypeDescriptor targetType) sourceType のオブジェクトを targetType に変換できる場合は、true を返します。 |
<T> T | convert(ObjectSE source, ClassSE<T> targetType) 指定された source を指定された targetType に変換します。 |
ObjectSE | convert(ObjectSE source, TypeDescriptor sourceType, TypeDescriptor targetType) 指定された source を指定された targetType に変換します。 |
boolean canConvert(@Nullable ClassSE<?> sourceType, ClassSE<?> targetType)
sourceType
のオブジェクトを targetType
に変換できる場合は、true
を返します。 このメソッドが true
を返す場合、convert(Object, Class)
が sourceType
のインスタンスを targetType
に変換できることを意味します。
コレクション、配列、マップ型に関する特記事項: コレクション、配列、マップ型間の変換では、基礎となる要素が変換可能でない場合に変換呼び出しが ConversionException
を生成する場合でも、このメソッドは true
を返します。呼び出し元は、コレクションとマップを操作するときにこの例外的なケースを処理することが期待されています。
sourceType
- 変換元のソース型 (ソースが null
の場合、null
になる場合があります)targetType
- 変換するターゲット型 (必須)true
、そうでない場合は false
IllegalArgumentExceptionSE
- targetType
が null
の場合 boolean canConvert(@Nullable TypeDescriptor sourceType, TypeDescriptor targetType)
sourceType
のオブジェクトを targetType
に変換できる場合は、true
を返します。TypeDescriptors は、変換が発生するソースとターゲットの場所(多くの場合、オブジェクトフィールドまたはプロパティの場所)に関する追加のコンテキストを提供します。 このメソッドが true
を返す場合、convert(Object, TypeDescriptor, TypeDescriptor)
が sourceType
のインスタンスを targetType
に変換できることを意味します。
コレクション、配列、マップ型に関する特記事項: コレクション、配列、マップ型間の変換では、基礎となる要素が変換可能でない場合に変換呼び出しが ConversionException
を生成する場合でも、このメソッドは true
を返します。呼び出し元は、コレクションとマップを操作するときにこの例外的なケースを処理することが期待されています。
sourceType
- 変換元のソース型に関するコンテキスト (ソースが null
の場合、null
になる場合があります)targetType
- 変換するターゲット型に関するコンテキスト (必須)true
、そうでない場合は false
IllegalArgumentExceptionSE
- targetType
が null
の場合 @Nullable <T> T convert(@Nullable ObjectSE source, ClassSE<T> targetType)
source
を指定された targetType
に変換します。source
- 変換するソースオブジェクト (null
の場合があります)targetType
- 変換するターゲット型 (必須)ConversionException
- 変換例外が発生した場合 IllegalArgumentExceptionSE
- targetType が null
の場合 @Nullable ObjectSE convert(@Nullable ObjectSE source, @Nullable TypeDescriptor sourceType, TypeDescriptor targetType)
source
を指定された targetType
に変換します。TypeDescriptors は、変換が発生するソースおよびターゲットの場所(多くの場合、オブジェクトフィールドまたはプロパティの場所)に関する追加のコンテキストを提供します。source
- 変換するソースオブジェクト (null
の場合があります)sourceType
- 変換元のソース型に関するコンテキスト (ソースが null
の場合、null
になる場合があります)targetType
- 変換するターゲット型に関するコンテキスト (必須)targetType
のインスタンス ConversionException
- 変換例外が発生した場合 IllegalArgumentExceptionSE
- targetType が null
、または sourceType
が null
であるが、ソースが null
でない場合