Package org.osgi.util.converter
Class ConvertingImpl
- All Implemented Interfaces:
Converting
,InternalConverting
,Specifying<Converting>
class ConvertingImpl
extends AbstractSpecifying<Converting>
implements Converting, InternalConverting
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) InternalConverter
private static final Collection<Class<?>>
private Object
private Class<?>
private Class<?>
private Type
private Type[]
Fields inherited from class org.osgi.util.converter.AbstractSpecifying
defaultValue, hasDefault, keysIgnoreCase, liveView, sourceAsClass, sourceAsDTO, sourceAsJavaBean, targetAsClass, targetAsDTO, targetAsJavaBean
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static Object
asBoxedArray
(Object obj) private Collection<?>
private Collection<?>
private Object
convertArrayToSingleValue
(Class<?> cls) private Object
convertCollectionToSingleValue
(Class<?> cls) (package private) Object
convertCollectionValue
(Object element) private Object
convertMapElement
(Object element, int typeIdx) private Object
convertMapEntryToSingleValue
(Class<?> cls) (package private) Object
convertMapKey
(Object key) private Object
convertMapToSingleValue
(Class<?> cls) (package private) Object
convertMapValue
(Object value) private <T> T
convertToArray
(Class<?> componentClz, Type componentType) private <T> T
private Collection<?>
private <T> T
private Object
private <T> T
convertToDTO
(Class<?> sourceCls, Class<?> targetAsCls) private Object
convertToInterface
(Class<?> sourceCls, Class<?> targetCls) private Object
convertToJavaBean
(Class<?> sourceCls, Class<?> targetCls) private Map
private Map
private Object
private static Map
createMapFromBeanAccessors
(Object obj, Class<?> sourceCls) private Map
createMapFromDTO
(Object obj, InternalConverter ic) private static Map
createMapFromInterface
(Object obj, Class<?> srcCls) private static Object
createMapOrCollection
(Class<?> cls, int initialSize) private Object
createProxy
(Class<?> cls, Map<?, ?> data) private static Class<?>
getConstructableType
(Class<?> targetCls) getInterfaces
(Class<?> cls) getInterfaces0
(Class<?> cls) private Map<?,
?> getPropertiesDelegate
(Object obj, Class<?> cls) getSetters
(Class<?> cls) private static void
private void
handleDTOField
(Object obj, Field field, Set<String> handledFields, Map result, InternalConverter ic) private static void
private Object
handleNull
(Class<?> cls) private boolean
hasGetProperties
(Class<?> cls) private static boolean
isCopyRequiredType
(Class<?> cls) private static boolean
private boolean
isMarkerAnnotation
(Class<?> annClass) private static boolean
isWriteableJavaBean
(Class<?> cls) private Map<?,
?> mapView
(Object obj, Class<?> sourceCls, InternalConverter ic) (package private) static Type
void
Set the current converter.<T> T
Specify the target object type for the conversion as a class object.<T> T
Specify the target object type as a Java Reflection Type object.<T> T
to
(TypeReference<T> ref) Specify the target object type as aTypeReference
.private Object
private <T> T
Methods inherited from class org.osgi.util.converter.AbstractSpecifying
defaultValue, keysIgnoreCase, sourceAs, sourceAsBean, sourceAsDTO, targetAs, targetAsBean, targetAsDTO, view
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.osgi.util.converter.Specifying
defaultValue, keysIgnoreCase, sourceAs, sourceAsBean, sourceAsDTO, targetAs, targetAsBean, targetAsDTO, view
-
Field Details
-
INTERFACE_IMPLS
-
NO_MAP_VIEW_TYPES
-
converter
-
object
-
sourceClass
-
targetClass
-
typeArguments
-
targetType
-
-
Constructor Details
-
ConvertingImpl
ConvertingImpl(InternalConverter c, Object obj)
-
-
Method Details
-
setConverter
Description copied from interface:InternalConverting
Set the current converter.- Specified by:
setConverter
in interfaceInternalConverting
- Parameters:
c
- The current converter.
-
to
Description copied from interface:Converting
Specify the target object type for the conversion as a class object.- Specified by:
to
in interfaceConverting
- Parameters:
cls
- The class to convert to.- Returns:
- The converted object.
-
to
Description copied from interface:Converting
Specify the target object type as aTypeReference
. If the target class carries generics information a TypeReference should be used as this preserves the generic information whereas a Class object has this information erased. Example use:List<String> result = converter.convert(Arrays.asList(1, 2, 3)) .to(new TypeReference<List<String>>() {});
- Specified by:
to
in interfaceConverting
- Parameters:
ref
- A type reference to the object being converted to.- Returns:
- The converted object.
-
to
Description copied from interface:Converting
Specify the target object type as a Java Reflection Type object.- Specified by:
to
in interfaceConverting
- Parameters:
type
- A Type object to represent the target type to be converted to.- Returns:
- The converted object.
-
convertArrayToSingleValue
-
convertCollectionToSingleValue
-
convertMapToSingleValue
-
convertMapEntryToSingleValue
-
convertToArray
-
convertToCollectionType
private <T> T convertToCollectionType() -
convertToCollectionDelegate
-
convertToCollection
private <T> T convertToCollection() -
convertToDTO
-
reifyType
-
getNames
-
convertToMap
-
convertCollectionValue
-
convertMapKey
-
convertMapValue
-
convertMapElement
-
convertToMapDelegate
-
convertToMapType
-
convertToDictionary
-
convertToJavaBean
-
convertToInterface
-
createProxy
-
handleNull
-
isMapType
-
trySpecialCases
-
isMarkerAnnotation
-
tryStandardMethods
private <T> T tryStandardMethods() -
collectionView
-
asCollection
-
asBoxedArray
-
createMapFromBeanAccessors
-
createMapFromDTO
-
createMapFromInterface
-
createMapOrCollection
-
getConstructableType
-
getInterfaces
-
getInterfaces0
-
handleDTOField
-
handleBeanMethod
-
handleInterfaceMethod
-
mapView
-
hasGetProperties
-
getPropertiesDelegate
-
isCopyRequiredType
-
isWriteableJavaBean
-
getSetters
-