Interface BeanMapper

    • Method Detail

      • map

        <T> T map​(Object source,
                  Class<T> targetClass)
        Recursively converts the given source Object to the given target Class.
        Type Parameters:
        T - is the generic type to convert to.
        Parameters:
        source - is the object to convert.
        targetClass - is the Class reflecting the type to convert to.
        Returns:
        the converted object. Will be null if source is null.
      • mapTypesafe

        <API,​S extends API,​T extends API> T mapTypesafe​(Class<API> apiClass,
                                                                    S source,
                                                                    Class<T> targetClass)
        A type-safe variant of map(Object, Class) to prevent accidental abuse (e.g. mapping of apples to bananas).
        Type Parameters:
        API - is a common super-type (interface) of source and targetType.
        S - is the generic type of source.
        T - is the generic type to convert to (target).
        Parameters:
        apiClass - is the Class reflecting the <API>.
        source - is the object to convert.
        targetClass - is the Class reflecting the type to convert to.
        Returns:
        the converted object. Will be null if source is null.
        Since:
        1.3.0
      • mapList

        <T> List<T> mapList​(List<?> source,
                            Class<T> targetClass)
        Creates a new List with the mapped bean for each entry of the given List. Uses false for suppressNullValues (see mapList(List, Class, boolean)).
        Type Parameters:
        T - is the generic type to convert the List entries to.
        Parameters:
        source - is the List with the source objects.
        targetClass - is the Class reflecting the type to convert each List entry to.
        Returns:
        the List with the converted objects. Will be empty is source is empty or null.
      • mapList

        <T> List<T> mapList​(List<?> source,
                            Class<T> targetClass,
                            boolean suppressNullValues)
        Creates a new List with the mapped bean for each entry of the given List.
        Type Parameters:
        T - is the generic type to convert the List entries to.
        Parameters:
        source - is the List with the source objects.
        targetClass - is the Class reflecting the type to convert each List entry to.
        suppressNullValues - true if null values shall be suppressed/omitted in the resulting List, false otherwise.
        Returns:
        the List with the converted objects. Will be empty is source is empty or null.
        Since:
        1.3.0
      • mapSet

        <T> Set<T> mapSet​(Set<?> source,
                          Class<T> targetClass)
        Creates a new Set with the mapped bean for each entry of the given Set. Uses false for suppressNullValues (see mapSet(Set, Class, boolean)).
        Type Parameters:
        T - is the generic type to convert the Set entries to.
        Parameters:
        source - is the Set with the source objects.
        targetClass - is the Class reflecting the type to convert each Set entry to.
        Returns:
        the Set with the converted objects. Will be empty is source is empty or null.
      • mapSet

        <T> Set<T> mapSet​(Set<?> source,
                          Class<T> targetClass,
                          boolean suppressNullValues)
        Creates a new Set with the mapped bean for each entry of the given Set.
        Type Parameters:
        T - is the generic type to convert the Set entries to.
        Parameters:
        source - is the Set with the source objects.
        targetClass - is the Class reflecting the type to convert each Set entry to.
        suppressNullValues - true if null values shall be suppressed/omitted in the resulting Set, false otherwise.
        Returns:
        the Set with the converted objects. Will be empty is source is empty or null.
        Since:
        1.3.0