S - The source typeT - The target type@SPI @FunctionalInterface public interface Converter<S,T> extends Prioritized
COMPARATOR, MAX_PRIORITY, MIN_PRIORITY, NORMAL_PRIORITY| 限定符和类型 | 方法和说明 |
|---|---|
default boolean |
accept(Class<?> sourceType,
Class<?> targetType)
Accept the source type and target type or not
|
T |
convert(S source)
Convert the source-typed value to the target-typed value
|
static <T> T |
convertIfPossible(Object source,
Class<T> targetType)
Convert the value of source to target-type value if possible
|
static Converter<?,?> |
getConverter(Class<?> sourceType,
Class<?> targetType)
Get the Converter instance from
ExtensionLoader with the specified source and target type |
default Class<S> |
getSourceType()
Get the source type
|
default Class<T> |
getTargetType()
Get the target type
|
compareTo, getPrioritydefault boolean accept(Class<?> sourceType, Class<?> targetType)
sourceType - the source typetargetType - the target typetrue, or falseT convert(S source)
source - the source-typed valuestatic Converter<?,?> getConverter(Class<?> sourceType, Class<?> targetType)
ExtensionLoader with the specified source and target typesourceType - the source typetargetType - the target typeExtensionLoader.getSupportedExtensionInstances()Copyright © 2011–2023 The Apache Software Foundation. All rights reserved.