-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added list mapper * Refactored old hacky list handling with new one * Fixed failing test
- Loading branch information
1 parent
f557db1
commit e1efa07
Showing
18 changed files
with
145 additions
and
399 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
plume/src/main/kotlin/io/github/plume/oss/domain/mappers/ListMapper.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package io.github.plume.oss.domain.mappers | ||
|
||
import scala.jdk.CollectionConverters | ||
|
||
/** | ||
* Contains functions to serialize and deserialize Scala lists. | ||
*/ | ||
object ListMapper { | ||
|
||
/** | ||
* Converts a given Scala list to a string for serialization. | ||
* | ||
* @param list The list to convert. | ||
* @return a comma-delimited string. | ||
*/ | ||
fun scalaListToString(list: scala.collection.immutable.List<*>): String = | ||
CollectionConverters.IterableHasAsJava(list).asJava().joinToString(separator = ",") | ||
|
||
/** | ||
* Converts a serialized list to a Scala list. | ||
* | ||
* @param string The string to convert. | ||
* @return a Scala list of the given type. | ||
*/ | ||
fun stringToScalaList(string: String): scala.collection.immutable.List<String> { | ||
val list = if (string.isBlank()) emptyList() else string.split(',').toList() | ||
return CollectionConverters.ListHasAsScala(list).asScala().toList() | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.