Class CustomConverterImpl.ConvertingWrapper

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Converting defaultValue​(java.lang.Object defVal)
      The default value to use when the object cannot be converted or in case of conversion from a null value.
      Converting keysIgnoreCase()
      When converting between map-like types use case-insensitive mapping of keys.
      void setConverter​(Converter c)
      Set the current converter.
      Converting sourceAs​(java.lang.Class<?> type)
      Treat the source object as the specified class.
      Converting sourceAsBean()
      Treat the source object as a JavaBean.
      Converting sourceAsDTO()
      Treat the source object as a DTO even if the source object has methods or is otherwise not recognized as a DTO.
      Converting targetAs​(java.lang.Class<?> cls)
      Treat the target object as the specified class.
      Converting targetAsBean()
      Treat the target object as a JavaBean.
      Converting targetAsDTO()
      Treat the target object as a DTO even if it has methods or is otherwise not recognized as a DTO.
      <T> T to​(java.lang.Class<T> cls)
      Specify the target object type for the conversion as a class object.
      <T> T to​(java.lang.reflect.Type type)
      Specify the target object type as a Java Reflection Type object.
      <T> T to​(TypeReference<T> ref)
      Specify the target object type as a TypeReference.
      java.lang.String toString()  
      Converting view()
      Return a live view over the backing object that reflects any changes to the original object.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • object

        private final java.lang.Object object
      • defaultValue

        private volatile java.lang.Object defaultValue
      • hasDefault

        private volatile boolean hasDefault
    • Constructor Detail

    • Method Detail

      • view

        public Converting view()
        Description copied from interface: Specifying
        Return a live view over the backing object that reflects any changes to the original object. This is only possible with conversions to Map, Collection, List and Set. The live view object will cease to be live as soon as modifications are made to it. Note that conversions to an interface or annotation will always produce a live view that cannot be modified. This modifier has no effect with conversions to other types.
        Specified by:
        view in interface Specifying<Converting>
        Returns:
        The current Converting object so that additional calls can be chained.
      • defaultValue

        public Converting defaultValue​(java.lang.Object defVal)
        Description copied from interface: Specifying
        The default value to use when the object cannot be converted or in case of conversion from a null value.
        Specified by:
        defaultValue in interface Specifying<Converting>
        Parameters:
        defVal - The default value.
        Returns:
        The current Converting object so that additional calls can be chained.
      • keysIgnoreCase

        public Converting keysIgnoreCase()
        Description copied from interface: Specifying
        When converting between map-like types use case-insensitive mapping of keys.
        Specified by:
        keysIgnoreCase in interface Specifying<Converting>
        Returns:
        The current Converting object so that additional calls can be chained.
      • sourceAs

        public Converting sourceAs​(java.lang.Class<?> type)
        Description copied from interface: Specifying
        Treat the source object as the specified class. This can be used to disambiguate a type if it implements multiple interfaces or extends multiple classes.
        Specified by:
        sourceAs in interface Specifying<Converting>
        Parameters:
        type - The class to treat the object as.
        Returns:
        The current Converting object so that additional calls can be chained.
      • sourceAsBean

        public Converting sourceAsBean()
        Description copied from interface: Specifying
        Treat the source object as a JavaBean. By default objects will not be treated as JavaBeans, this has to be specified using this method.
        Specified by:
        sourceAsBean in interface Specifying<Converting>
        Returns:
        The current Converting object so that additional calls can be chained.
      • sourceAsDTO

        public Converting sourceAsDTO()
        Description copied from interface: Specifying
        Treat the source object as a DTO even if the source object has methods or is otherwise not recognized as a DTO.
        Specified by:
        sourceAsDTO in interface Specifying<Converting>
        Returns:
        The current Converting object so that additional calls can be chained.
      • targetAs

        public Converting targetAs​(java.lang.Class<?> cls)
        Description copied from interface: Specifying
        Treat the target object as the specified class. This can be used to disambiguate a type if it implements multiple interfaces or extends multiple classes.
        Specified by:
        targetAs in interface Specifying<Converting>
        Parameters:
        cls - The class to treat the object as.
        Returns:
        The current Converting object so that additional calls can be chained.
      • targetAsBean

        public Converting targetAsBean()
        Description copied from interface: Specifying
        Treat the target object as a JavaBean. By default objects will not be treated as JavaBeans, this has to be specified using this method.
        Specified by:
        targetAsBean in interface Specifying<Converting>
        Returns:
        The current Converting object so that additional calls can be chained.
      • targetAsDTO

        public Converting targetAsDTO()
        Description copied from interface: Specifying
        Treat the target object as a DTO even if it has methods or is otherwise not recognized as a DTO.
        Specified by:
        targetAsDTO in interface Specifying<Converting>
        Returns:
        The current Converting object so that additional calls can be chained.
      • 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.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object