Class ConvertingImpl

All Implemented Interfaces:
Converting, InternalConverting, Specifying<Converting>

class ConvertingImpl extends AbstractSpecifying<Converting> implements Converting, InternalConverting
  • Field Details

    • INTERFACE_IMPLS

      private static final Map<Class<?>,Class<?>> INTERFACE_IMPLS
    • NO_MAP_VIEW_TYPES

      private static final Collection<Class<?>> NO_MAP_VIEW_TYPES
    • converter

      volatile InternalConverter converter
    • object

      private volatile Object object
    • sourceClass

      private volatile Class<?> sourceClass
    • targetClass

      private volatile Class<?> targetClass
    • typeArguments

      private volatile Type[] typeArguments
    • targetType

      private volatile Type targetType
  • Constructor Details

  • Method Details

    • setConverter

      public void setConverter(Converter c)
      Description copied from interface: InternalConverting
      Set the current converter.
      Specified by:
      setConverter in interface InternalConverting
      Parameters:
      c - The current converter.
    • to

      public <T> T to(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(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 Object convertArrayToSingleValue(Class<?> cls)
    • convertCollectionToSingleValue

      private Object convertCollectionToSingleValue(Class<?> cls)
    • convertMapToSingleValue

      private Object convertMapToSingleValue(Class<?> cls)
    • convertMapEntryToSingleValue

      private Object convertMapEntryToSingleValue(Class<?> cls)
    • convertToArray

      private <T> T convertToArray(Class<?> componentClz, Type componentType)
    • convertToCollectionType

      private <T> T convertToCollectionType()
    • convertToCollectionDelegate

      private Collection<?> convertToCollectionDelegate()
    • convertToCollection

      private <T> T convertToCollection()
    • convertToDTO

      private <T> T convertToDTO(Class<?> sourceCls, Class<?> targetAsCls)
    • reifyType

      static Type reifyType(Type typeToReify, Class<?> ownerClass, Type[] typeArgs)
    • getNames

      private List<String> getNames(Class<?> cls)
    • convertToMap

      private Map convertToMap()
    • convertCollectionValue

      Object convertCollectionValue(Object element)
    • convertMapKey

      Object convertMapKey(Object key)
    • convertMapValue

      Object convertMapValue(Object value)
    • convertMapElement

      private Object convertMapElement(Object element, int typeIdx)
    • convertToMapDelegate

      private Map convertToMapDelegate()
    • convertToMapType

      private Object convertToMapType()
    • convertToDictionary

      private Object convertToDictionary()
    • convertToJavaBean

      private Object convertToJavaBean(Class<?> sourceCls, Class<?> targetCls)
    • convertToInterface

      private Object convertToInterface(Class<?> sourceCls, Class<?> targetCls)
    • createProxy

      private Object createProxy(Class<?> cls, Map<?,?> data)
    • handleNull

      private Object handleNull(Class<?> cls)
    • isMapType

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

      private Object trySpecialCases()
    • isMarkerAnnotation

      private boolean isMarkerAnnotation(Class<?> annClass)
    • tryStandardMethods

      private <T> T tryStandardMethods()
    • collectionView

      private Collection<?> collectionView()
    • asCollection

      private Collection<?> asCollection()
    • asBoxedArray

      private static Object asBoxedArray(Object obj)
    • createMapFromBeanAccessors

      private static Map createMapFromBeanAccessors(Object obj, Class<?> sourceCls)
    • createMapFromDTO

      private Map createMapFromDTO(Object obj, InternalConverter ic)
    • createMapFromInterface

      private static Map createMapFromInterface(Object obj, Class<?> srcCls)
    • createMapOrCollection

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

      private static Class<?> getConstructableType(Class<?> targetCls)
    • getInterfaces

      private static Set<Class<?>> getInterfaces(Class<?> cls)
    • getInterfaces0

      private static Set<Class<?>> getInterfaces0(Class<?> cls)
    • handleDTOField

      private void handleDTOField(Object obj, Field field, Set<String> handledFields, Map result, InternalConverter ic)
    • handleBeanMethod

      private static void handleBeanMethod(Object obj, Method md, Set<String> invokedMethods, Map res)
    • handleInterfaceMethod

      private static void handleInterfaceMethod(Object obj, Class<?> intf, Method md, Set<String> invokedMethods, Map res)
    • mapView

      private Map<?,?> mapView(Object obj, Class<?> sourceCls, InternalConverter ic)
    • hasGetProperties

      private boolean hasGetProperties(Class<?> cls)
    • getPropertiesDelegate

      private Map<?,?> getPropertiesDelegate(Object obj, Class<?> cls)
    • isCopyRequiredType

      private static boolean isCopyRequiredType(Class<?> cls)
    • isWriteableJavaBean

      private static boolean isWriteableJavaBean(Class<?> cls)
    • getSetters

      private static Set<Method> getSetters(Class<?> cls)