Interface Converting

  • All Superinterfaces:
    Specifying<Converting>

    @ProviderType
    public interface Converting
    extends Specifying<Converting>
    This interface is used to specify the target that an object should be converted to. A Converting instance can be obtained via the Converter.
    Author:
    $Id: 228131c26832a3d3dc016ec3090cf5d3b474df4e $
    • Method Detail

      • to

        <T> T to​(java.lang.Class<T> cls)
        Specify the target object type for the conversion as a class object.
        Parameters:
        cls - The class to convert to.
        Returns:
        The converted object.
      • to

        <T> T to​(java.lang.reflect.Type type)
        Specify the target object type as a Java Reflection Type object.
        Parameters:
        type - A Type object to represent the target type to be converted to.
        Returns:
        The converted object.
      • to

        <T> T to​(TypeReference<T> ref)
        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>>() {});
         
        Parameters:
        ref - A type reference to the object being converted to.
        Returns:
        The converted object.