Skip to content

Commit 2af278e

Browse files
committed
Feedback from code review: renaming the *MappingConverter.kt files to be plural; adding example of list mapping converter usage; correcting typos
1 parent 7f65a5d commit 2af278e

File tree

4 files changed

+14
-3
lines changed

4 files changed

+14
-3
lines changed

hll/hll-mapping-core/README.md

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# HLL Converters
22

3-
This package and subpackages provide a framework for typed data mapping, including base interfaces and some reusable
4-
implementations. This document describes the theory behind the conversion framework and how it may be applied.
3+
This module provides a framework for typed data mapping, including base interfaces and some reusable implementations.
4+
This document describes the theory behind the conversion framework and how it may be applied.
55

66
## Terminology
77

@@ -135,7 +135,7 @@ Converters may be wrapped by a collection converter in order to transform collec
135135

136136
![](docs/img/element-mapping-converter.png)
137137

138-
Collection converters are typically build using factory functions which accept one or more delegate converters as
138+
Collection converters are typically built using factory functions which accept one or more delegate converters as
139139
arguments. For example:
140140

141141
```kotlin
@@ -144,3 +144,14 @@ fun <L, R> ListMappingConverter(delegate: Converter<L, R>): Converter<List<L>, L
144144

145145
The preceding function creates a converter which transforms between `List<L>` and `List<R>` by mapping over each element
146146
and using the delegate converter to transform between element types `L` and `R`.
147+
148+
The following example illustrates composing an element converter with a list mapping converter:
149+
150+
```kotlin
151+
val intToLong: Converter<Int, Long> = ...
152+
val intListToLongList: Converter<List<Int>, List<Long>> = ListMappingConverter(intToLong)
153+
```
154+
155+
In the preceding example, `intToLong` is passed as a delegate to the `ListMappingConverter` factory function and a list
156+
mapping converter is returned. When a list is transformed through this converter, each element is passed to the delegate
157+
for individual transformation in either direction.

0 commit comments

Comments
 (0)