Skip to content

Provide a method on Datatable to map to list of custom type #83

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
gaeljw opened this issue Jun 13, 2020 · 0 comments · Fixed by #85
Closed

Provide a method on Datatable to map to list of custom type #83

gaeljw opened this issue Jun 13, 2020 · 0 comments · Fixed by #85
Assignees
Labels
⚡ enhancement Request for new functionality
Milestone

Comments

@gaeljw
Copy link
Member

gaeljw commented Jun 13, 2020

Is your feature request related to a problem? Please describe.

Since version 6.x, we can benefit of extension methods to the Datatable class to map them to Scala collection types easily. But it assumes that we are converting only to basic types and always wrap the values in an Option.

This is not necessary for custom types registered with a DataTableType as we can assume that a scala DataTableType never returns null.

Describe the solution you'd like

We should be able to do map a Datatable to a list of custom types not wrapped in Option.

DataTableType { map: Map[String,String] =>
  // map to CustomType
}

Given("the following table as Scala List of custom type") { (table: DataTable) =>
  // We want this:
  val data: Seq[CustomType] = table.asScalaRawList[CustomType]
  // Instead of:
  val data: Seq[Option[CustomType]] = table.asScalaList[CustomType]
  // ...
}
@gaeljw gaeljw added the ⚡ enhancement Request for new functionality label Jun 13, 2020
@gaeljw gaeljw added this to the 6.2.0 milestone Jun 13, 2020
@gaeljw gaeljw self-assigned this Jun 13, 2020
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
⚡ enhancement Request for new functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant