Package io.microsphere.convert.multiple
Interface MultiValueConverter<S>
-
- Type Parameters:
S
- The source type
- All Superinterfaces:
java.lang.Comparable<Prioritized>
,Prioritized
- All Known Subinterfaces:
StringToMultiValueConverter
- All Known Implementing Classes:
StringToArrayConverter
,StringToBlockingDequeConverter
,StringToBlockingQueueConverter
,StringToCollectionConverter
,StringToDequeConverter
,StringToIterableConverter
,StringToListConverter
,StringToNavigableSetConverter
,StringToQueueConverter
,StringToSetConverter
,StringToSortedSetConverter
,StringToTransferQueueConverter
public interface MultiValueConverter<S> extends Prioritized
An interface to convert the source-typed value to multiple value, e.g , Java array,Collection
or sub-interfaces- Since:
- 1.0.0
-
-
Field Summary
-
Fields inherited from interface io.microsphere.lang.Prioritized
COMPARATOR, MAX_PRIORITY, MIN_PRIORITY, NORMAL_PRIORITY
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description boolean
accept(java.lang.Class<S> sourceType, java.lang.Class<?> multiValueType)
Accept the source type and target type or notjava.lang.Object
convert(S source, java.lang.Class<?> multiValueType, java.lang.Class<?> elementType)
Convert the source to be the multiple valuestatic <T> T
convertIfPossible(java.lang.Object source, java.lang.Class<?> multiValueType, java.lang.Class<?> elementType)
static MultiValueConverter<?>
find(java.lang.Class<?> sourceType, java.lang.Class<?> targetType)
Find theMultiValueConverter
instance fromServiceLoader
with the specified source and target typedefault java.lang.Class<S>
getSourceType()
Get the source type-
Methods inherited from interface io.microsphere.lang.Prioritized
compareTo, getPriority
-
-
-
-
Method Detail
-
accept
boolean accept(java.lang.Class<S> sourceType, java.lang.Class<?> multiValueType)
Accept the source type and target type or not- Parameters:
sourceType
- the source typemultiValueType
- the multi-value type- Returns:
- if accepted, return
true
, orfalse
-
convert
java.lang.Object convert(S source, java.lang.Class<?> multiValueType, java.lang.Class<?> elementType)
Convert the source to be the multiple value- Parameters:
source
- the source-typed valuemultiValueType
- the multi-value typeelementType
- the element type- Returns:
-
getSourceType
default java.lang.Class<S> getSourceType()
Get the source type- Returns:
- non-null
-
find
static MultiValueConverter<?> find(java.lang.Class<?> sourceType, java.lang.Class<?> targetType)
Find theMultiValueConverter
instance fromServiceLoader
with the specified source and target type- Parameters:
sourceType
- the source typetargetType
- the target type- Returns:
null
if not found
-
convertIfPossible
static <T> T convertIfPossible(java.lang.Object source, java.lang.Class<?> multiValueType, java.lang.Class<?> elementType)
-
-