10000 io-to-data.7 : extract generate · java-to-kotlin/code@2f7a705 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2f7a705

Browse files
Duncan McGregordmcg
authored andcommitted
io-to-data.7 : extract generate
1 parent 0a5b391 commit 2f7a705

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/main/java/travelator/marketing/HighValueCustomersReport.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,18 @@ import java.io.Writer
55

66
@Throws(IOException::class)
77
fun generate(writer: Writer, lines: List<String>) {
8+
val resultLines = generate(lines)
9+
writer.append(resultLines.joinToString("\n"))
10+
}
11+
12+
fun generate(lines: List<String>): List<String> {
813
val valuableCustomers = lines
914
.toValuableCustomers()
1015
.sortedBy(CustomerData::score)
1116
val resultLines = listOf("ID\tName\tSpend") +
1217
valuableCustomers.map(CustomerData::outputLine) +
1318
valuableCustomers.summarised()
14-
writer.append(resultLines.joinToString("\n"))
19+
return resultLines
1520
}
1621

1722
private fun List<String>.toValuableCustomers() = withoutHeader()

0 commit comments

Comments
 (0)
0