Skip to content

Conversation

@padamstx
Copy link
Contributor

This PR will allow dynamic models (subclasses of DynamicModel) to define a protected (or private) default ctor instead of a public one. We need this to accommodate the code pattern used by our new oneOf/anyOf processing whereby the parent schema (the schema containing the oneOf/anyOf list) will define a protected default ctor to prevent users from instantiating it (they would have to use a base class instead). For this reason, we need the DynamicModelTypeAdapterFactory class to recognize a non-public default ctor when checking to see if it should handle a specific class.

@padamstx padamstx requested a review from lpatino10 June 27, 2019 09:28
@padamstx padamstx self-assigned this Jun 27, 2019
@padamstx padamstx added the ready-for-review PR is ready for a review label Jun 27, 2019
@lpatino10
Copy link
Contributor

Hey Phil, I get the rationale of needing a protected constructor for the oneOf/anyOf support from your demo yesterday, but I'm not 100% clear on the impact to the generated Watson Java SDK as it stands now. This won't remove any generated constructors, just allow for new ones, right?

Just want to make sure it's not a breaking change or anything, because otherwise it looks good to me.

@padamstx
Copy link
Contributor Author

This change in the java core simply makes the DynamicModelTypeAdapterFactory work correctly if the model class in question has a non-public default ctor, where previously it would only recognize models with a public default ctor. So this, in and of itself, doesn't change any generated code or introduce any sort of breaking changes. Instead, it will be needed for situations where we generate a base class for a schema that uses oneOf (and also uses additionalProperties, making it a dynamic model) because in that narrow case we'll make the default ctor protected (instead of public) to prevent users from instantiating the base class directly.

tl;dr... no this won't introduce any breaking changes :)

Copy link
Contributor

@lpatino10 lpatino10 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good! In that case I approve.

@germanattanasio
Copy link
Contributor

Will this affect users trying to set values in the assistant context and send it back as a new message? I've seen users having issues using the setters in subsequent requests to /message

@padamstx
Copy link
Contributor Author

padamstx commented Jul 8, 2019

Will this affect users trying to set values in the assistant context and send it back as a new message? I've seen users having issues using the setters in subsequent requests to /message

No :)

@padamstx padamstx merged commit b9fabd3 into master Jul 8, 2019
@padamstx padamstx deleted the dynmodel-update branch August 14, 2019 04:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-review PR is ready for a review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants