final class ByteBufferConverter extends java.lang.Object implements ConditionalGenericConverter
ByteBuffer
directly to and from byte[]
s and indirectly to
any type that the ConversionService
support via byte[]
.GenericConverter.ConvertiblePair
Modifier and Type | Field and Description |
---|---|
private static TypeDescriptor |
BYTE_ARRAY_TYPE |
private static TypeDescriptor |
BYTE_BUFFER_TYPE |
private ConversionService |
conversionService |
private static java.util.Set<GenericConverter.ConvertiblePair> |
CONVERTIBLE_PAIRS |
Constructor and Description |
---|
ByteBufferConverter(ConversionService conversionService) |
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
convert(java.lang.Object source,
TypeDescriptor sourceType,
TypeDescriptor targetType)
Convert the source to the targetType described by the TypeDescriptor.
|
private java.lang.Object |
convertFromByteBuffer(java.nio.ByteBuffer source,
TypeDescriptor targetType) |
private java.lang.Object |
convertToByteBuffer(java.lang.Object source,
TypeDescriptor sourceType) |
java.util.Set<GenericConverter.ConvertiblePair> |
getConvertibleTypes()
Return the source and target types which this converter can convert between.
|
boolean |
matches(TypeDescriptor sourceType,
TypeDescriptor targetType)
Should the conversion from
sourceType to targetType currently under
consideration be selected? |
private boolean |
matchesFromByteBuffer(TypeDescriptor targetType) |
private boolean |
matchesToByteBuffer(TypeDescriptor sourceType) |
private static final TypeDescriptor BYTE_BUFFER_TYPE
private static final TypeDescriptor BYTE_ARRAY_TYPE
private static final java.util.Set<GenericConverter.ConvertiblePair> CONVERTIBLE_PAIRS
private ConversionService conversionService
public ByteBufferConverter(ConversionService conversionService)
public java.util.Set<GenericConverter.ConvertiblePair> getConvertibleTypes()
GenericConverter
For conditional
converters this method may return
null
to indicate all source-to-target pairs should be considered. *
getConvertibleTypes
in interface GenericConverter
public boolean matches(TypeDescriptor sourceType, TypeDescriptor targetType)
ConditionalConverter
sourceType
to targetType
currently under
consideration be selected?matches
in interface ConditionalConverter
sourceType
- the type descriptor of the field we are converting fromtargetType
- the type descriptor of the field we are converting toprivate boolean matchesFromByteBuffer(TypeDescriptor targetType)
private boolean matchesToByteBuffer(TypeDescriptor sourceType)
public java.lang.Object convert(java.lang.Object source, TypeDescriptor sourceType, TypeDescriptor targetType)
GenericConverter
convert
in interface GenericConverter
source
- the source object to convert (may be null)sourceType
- the type descriptor of the field we are converting fromtargetType
- the type descriptor of the field we are converting toprivate java.lang.Object convertFromByteBuffer(java.nio.ByteBuffer source, TypeDescriptor targetType)
private java.lang.Object convertToByteBuffer(java.lang.Object source, TypeDescriptor sourceType)