Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Casting Generic Function when applying it #42

Open
tiagofiliperdy opened this issue May 10, 2018 · 0 comments
Open

Casting Generic Function when applying it #42

tiagofiliperdy opened this issue May 10, 2018 · 0 comments

Comments

@tiagofiliperdy
Copy link
Contributor

At the moment a cast is being done in the Extraction Function to be able to provide it to an object called Transform which has a set of Type Classes for primitive types and collections of them. This is an example of the problem:

private def applyFunction(result: Iterable[Any],keyList: List[(String, String)],limitList: List[(Option[Int], Option[Int], String)], typeClass: Option[String], dotsList: List[String]): Any = {
...
case INTEGER if fExt.isDefined =>
val res: Seq[Int] = result.asInstanceOf[Iterable[Int]].toSeq
Try(Transform.toPrimitive(fExt.get.asInstanceOf[Seq[Int] => Unit], res)) match {
case Success() =>
case Failure(
) => throw CustomException(s"Type designated doens't correspond with extracted type: Seq[${typeClass.get}]")
}
...
}

The idea is to use Shapeless derivation of generic types to be able to provide the function to the Transform object without casting the function and the value to be applied in the function.

@tiagofiliperdy tiagofiliperdy changed the title Casting TypeClasses when applying Extract Function Casting Generic Function when applying it May 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant