Interface ToMapper<A,B>

Type Parameters:
A - the source type
B - the target type
All Known Subinterfaces:
Mapper<A,B>
All Known Implementing Classes:
MapperAdapter

public interface ToMapper<A,B>
One-way mapper from A to B.
  • Method Details

    • to

      default B to(A value)
      Maps a value of type A to type B.
      Parameters:
      value - the source value
      Returns:
      the mapped value
    • to

      B to(A value, MappingContext ctx)
      Maps a value of type A to type B using the supplied context.
      Parameters:
      value - the source value
      ctx - additional mapping context
      Returns:
      the mapped value
    • toAll

      default List<B> toAll(Iterable<? extends A> values)
      Maps all values in the provided iterable to a list.
      Parameters:
      values - the values to map
      Returns:
      the mapped values
    • toAll

      default List<B> toAll(Iterable<? extends A> values, MappingContext ctx)
      Maps all values in the provided iterable to a list using the supplied context.
      Parameters:
      values - the values to map
      ctx - additional mapping context
      Returns:
      the mapped values
    • toSet

      default Set<B> toSet(Iterable<? extends A> values)
      Maps all values in the provided iterable to a set.
      Parameters:
      values - the values to map
      Returns:
      the mapped values
    • toSet

      default Set<B> toSet(Iterable<? extends A> values, MappingContext ctx)
      Maps all values in the provided iterable to a set using the supplied context.
      Parameters:
      values - the values to map
      ctx - additional mapping context
      Returns:
      the mapped values
    • toCollection

      default <C extends Collection<B>> C toCollection(Iterable<? extends A> values, Supplier<C> collectionFactory)
      Maps all values in the provided iterable into a collection supplied by the caller.
      Type Parameters:
      C - the collection type
      Parameters:
      values - the values to map
      collectionFactory - the collection factory
      Returns:
      the mapped values
    • toCollection

      default <C extends Collection<B>> C toCollection(Iterable<? extends A> values, Supplier<C> collectionFactory, MappingContext ctx)
      Maps all values in the provided iterable into a collection supplied by the caller.
      Type Parameters:
      C - the collection type
      Parameters:
      values - the values to map
      collectionFactory - the collection factory
      ctx - additional mapping context
      Returns:
      the mapped values
    • toAllPreservingType

      default Collection<B> toAllPreservingType(Collection<? extends A> values)
      Maps all values in the provided iterable while preserving list/set semantics when possible.
      Parameters:
      values - the values to map
      Returns:
      the mapped collection
    • toAllPreservingType

      default Collection<B> toAllPreservingType(Collection<? extends A> values, MappingContext ctx)
      Maps all values in the provided iterable while preserving list/set semantics when possible.
      Parameters:
      values - the values to map
      ctx - additional mapping context
      Returns:
      the mapped collection
    • toStream

      default Stream<B> toStream(Iterable<? extends A> values)
      Maps the provided iterable to a stream.
      Parameters:
      values - the values to map
      Returns:
      the mapped stream
    • toStream

      default Stream<B> toStream(Iterable<? extends A> values, MappingContext ctx)
      Maps the provided iterable to a stream using the supplied context.
      Parameters:
      values - the values to map
      ctx - additional mapping context
      Returns:
      the mapped stream
    • toStream

      default Stream<B> toStream(Stream<? extends A> values, MappingContext ctx)
      Maps the provided stream using the supplied context.
      Parameters:
      values - the values to map
      ctx - additional mapping context
      Returns:
      the mapped stream
    • andThen

      default <C> ToMapper<A,C> andThen(ToMapper<? super B,? extends C> next)
      Chains this mapper with the next mapper.
      Type Parameters:
      C - the final target type
      Parameters:
      next - the next mapper
      Returns:
      the chained mapper