mtedone / podam

PODAM - POjo DAta Mocker
https://mtedone.github.io/podam
MIT License
326 stars 749 forks source link

Expose constructor index of parent pojo to TypeManufacturer #221

Closed devshorts closed 7 years ago

devshorts commented 8 years ago

I'm working on building a set of scala friendly type manufacturers and so far things work great. However, scala has crazy stuff which allow (through a bunch of weird indirection) primitives as the generic parameter of a container. For example:

Option[Int]

There are ways to determine the inner argument type by parsing the scala bytecode (this is what finatra jackson does), and thats fine. However, I can only find this information from the parent classes constructor arguments. This means that whenever I'm constructing my type, I need to inspect the containers arguments. But, since I don't have the currently constructing index I don't know which constructor parameter to look at.

For example:

case class OptionHolder(option1: Option[Long], option2: Option[Int])

I can determine both Long and Int if I know that the constructor parameter being constructed is the first or second. I can see see in getParameterValuesForConstructor that we do have the index. Is it possible to expose this on the attributeMetadata class?

daivanov commented 8 years ago

Yes, this has been a problem for a long time, but unfortunately Java doesn't allow to find a constructor index. But I think Podam can be passing constructor definition with an index of a parameter.

daivanov commented 8 years ago

A snapshot is available here.

devshorts commented 8 years ago

Awesome, thanks!

On Fri, Nov 4, 2016 at 4:58 PM, Daniil Ivanov notifications@github.com wrote:

A snapshot is available here https://oss.sonatype.org/content/repositories/snapshots/uk/co/jemos/podam/podam/7.0.2-SNAPSHOT/podam-7.0.2-20161104.235644-2.jar .

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/devopsfolks/podam/issues/221#issuecomment-258575304, or mute the thread https://github.com/notifications/unsubscribe-auth/ABt0srG-4L_Q9XihHUjAyd1QPzJNKBeeks5q68a5gaJpZM4Kmv3s .

daivanov commented 8 years ago

So what's your opinion about the change?