Class ConvertingImpl

    • Field Detail

      • INTERFACE_IMPLS

        private static final java.util.Map<java.lang.Class<?>,​java.lang.Class<?>> INTERFACE_IMPLS
      • NO_MAP_VIEW_TYPES

        private static final java.util.Collection<java.lang.Class<?>> NO_MAP_VIEW_TYPES
      • object

        private volatile java.lang.Object object
      • sourceClass

        private volatile java.lang.Class<?> sourceClass
      • targetClass

        private volatile java.lang.Class<?> targetClass
      • typeArguments

        private volatile java.lang.reflect.Type[] typeArguments
      • targetType

        private volatile java.lang.reflect.Type targetType
    • Constructor Detail

    • Method Detail

      • to

        public <T> T to​(java.lang.Class<T> cls)
        Description copied from interface: Converting
        Specify the target object type for the conversion as a class object.
        Specified by:
        to in interface Converting
        Parameters:
        cls - The class to convert to.
        Returns:
        The converted object.
      • to

        public <T> T to​(TypeReference<T> ref)
        Description copied from interface: Converting
        Specify the target object type as a TypeReference. 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 interface Converting
        Parameters:
        ref - A type reference to the object being converted to.
        Returns:
        The converted object.
      • to

        public <T> T to​(java.lang.reflect.Type type)
        Description copied from interface: Converting
        Specify the target object type as a Java Reflection Type object.
        Specified by:
        to in interface Converting
        Parameters:
        type - A Type object to represent the target type to be converted to.
        Returns:
        The converted object.
      • convertArrayToSingleValue

        private java.lang.Object convertArrayToSingleValue​(java.lang.Class<?> cls)
      • convertCollectionToSingleValue

        private java.lang.Object convertCollectionToSingleValue​(java.lang.Class<?> cls)
      • convertMapToSingleValue

        private java.lang.Object convertMapToSingleValue​(java.lang.Class<?> cls)
      • convertMapEntryToSingleValue

        private java.lang.Object convertMapEntryToSingleValue​(java.lang.Class<?> cls)
      • convertToArray

        private <T> T convertToArray​(java.lang.Class<?> componentClz,
                                     java.lang.reflect.Type componentType)
      • convertToCollectionType

        private <T> T convertToCollectionType()
      • convertToCollectionDelegate

        private java.util.Collection<?> convertToCollectionDelegate()
      • convertToCollection

        private <T> T convertToCollection()
      • convertToDTO

        private <T> T convertToDTO​(java.lang.Class<?> sourceCls,
                                   java.lang.Class<?> targetAsCls)
      • reifyType

        static java.lang.reflect.Type reifyType​(java.lang.reflect.Type typeToReify,
                                                java.lang.Class<?> ownerClass,
                                                java.lang.reflect.Type[] typeArgs)
      • getNames

        private java.util.List<java.lang.String> getNames​(java.lang.Class<?> cls)
      • convertToMap

        private java.util.Map convertToMap()
      • convertCollectionValue

        java.lang.Object convertCollectionValue​(java.lang.Object element)
      • convertMapKey

        java.lang.Object convertMapKey​(java.lang.Object key)
      • convertMapValue

        java.lang.Object convertMapValue​(java.lang.Object value)
      • convertMapElement

        private java.lang.Object convertMapElement​(java.lang.Object element,
                                                   int typeIdx)
      • convertToMapDelegate

        private java.util.Map convertToMapDelegate()
      • convertToMapType

        private java.lang.Object convertToMapType()
      • convertToDictionary

        private java.lang.Object convertToDictionary()
      • convertToJavaBean

        private java.lang.Object convertToJavaBean​(java.lang.Class<?> sourceCls,
                                                   java.lang.Class<?> targetCls)
      • convertToInterface

        private java.lang.Object convertToInterface​(java.lang.Class<?> sourceCls,
                                                    java.lang.Class<?> targetCls)
      • createProxy

        private java.lang.Object createProxy​(java.lang.Class<?> cls,
                                             java.util.Map<?,​?> data)
      • handleNull

        private java.lang.Object handleNull​(java.lang.Class<?> cls)
      • isMapType

        private static boolean isMapType​(java.lang.Class<?> cls,
                                         boolean asJavaBean,
                                         boolean asDTO)
      • trySpecialCases

        private java.lang.Object trySpecialCases()
      • isMarkerAnnotation

        private boolean isMarkerAnnotation​(java.lang.Class<?> annClass)
      • tryStandardMethods

        private <T> T tryStandardMethods()
      • collectionView

        private java.util.Collection<?> collectionView()
      • asCollection

        private java.util.Collection<?> asCollection()
      • asBoxedArray

        private static java.lang.Object asBoxedArray​(java.lang.Object obj)
      • createMapFromBeanAccessors

        private static java.util.Map createMapFromBeanAccessors​(java.lang.Object obj,
                                                                java.lang.Class<?> sourceCls)
      • createMapFromDTO

        private java.util.Map createMapFromDTO​(java.lang.Object obj,
                                               InternalConverter ic)
      • createMapFromInterface

        private static java.util.Map createMapFromInterface​(java.lang.Object obj,
                                                            java.lang.Class<?> srcCls)
      • createMapOrCollection

        private static java.lang.Object createMapOrCollection​(java.lang.Class<?> cls,
                                                              int initialSize)
      • getConstructableType

        private static java.lang.Class<?> getConstructableType​(java.lang.Class<?> targetCls)
      • getInterfaces

        private static java.util.Set<java.lang.Class<?>> getInterfaces​(java.lang.Class<?> cls)
      • getInterfaces0

        private static java.util.Set<java.lang.Class<?>> getInterfaces0​(java.lang.Class<?> cls)
      • handleDTOField

        private void handleDTOField​(java.lang.Object obj,
                                    java.lang.reflect.Field field,
                                    java.util.Set<java.lang.String> handledFields,
                                    java.util.Map result,
                                    InternalConverter ic)
      • handleBeanMethod

        private static void handleBeanMethod​(java.lang.Object obj,
                                             java.lang.reflect.Method md,
                                             java.util.Set<java.lang.String> invokedMethods,
                                             java.util.Map res)
      • handleInterfaceMethod

        private static void handleInterfaceMethod​(java.lang.Object obj,
                                                  java.lang.Class<?> intf,
                                                  java.lang.reflect.Method md,
                                                  java.util.Set<java.lang.String> invokedMethods,
                                                  java.util.Map res)
      • mapView

        private java.util.Map<?,​?> mapView​(java.lang.Object obj,
                                                 java.lang.Class<?> sourceCls,
                                                 InternalConverter ic)
      • hasGetProperties

        private boolean hasGetProperties​(java.lang.Class<?> cls)
      • getPropertiesDelegate

        private java.util.Map<?,​?> getPropertiesDelegate​(java.lang.Object obj,
                                                               java.lang.Class<?> cls)
      • isCopyRequiredType

        private static boolean isCopyRequiredType​(java.lang.Class<?> cls)
      • isWriteableJavaBean

        private static boolean isWriteableJavaBean​(java.lang.Class<?> cls)
      • getSetters

        private static java.util.Set<java.lang.reflect.Method> getSetters​(java.lang.Class<?> cls)