You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Solution 1: Add protected setters in Resource/ProxyResource
Pros
Seemingly the most simple to implement. In fact, current codegen's working like magic as it assumes setter methods on parent classes. There's not much(if not none) codegen work involved.
Cons
Protected setter methods are exposed though all Resource/ProxyResource's subclasses.
Solution 2: Add protected constructors in Resource/ProxyResource
Pros
Exposed less amount(1 vs 3) protected methods than the setter
Preserves the "read-only" nature of these properties, compared to "setter"
Cons
Protected constructor is exposed any way.
mgmt doesn't have constructors with parameters for now
Way more things to implement than protected setters.
Solution 3: Shadowing id, name, etc... in child classes, similar to #2639
Access helpers are defined in implementation packages and should be defined in the package implementation.accesshelpers
Similar as above, instead of exposing protected methods, it exposes unnecessary public Accessor Helper class.
Personal preference
From API's perspective, I prefer solution 3, which is the shadowing approach. It doesn't expose unnecessary APIs. Additionally, this may be consistent with the general case #2741, e.g. if the property is from parent and no public setter available, we shadow/duplicate it in child classes.
Haven't dived deep into each of the implementation. I assume all the solutions except solution 1(protected setters) involve getting some information of the base class(Resource/ProxyResource) to determine property's access pattern.
Issue
withId()is generated infromJsonimplementation, despite that it's not present onResourceorProxyResourceid,name, etc... inResourcecannot be accessed in child classesCurrent generated code:
Proposals:
Solution 1: Add protected setters in
Resource/ProxyResourcePros
Cons
Resource/ProxyResource's subclasses.Solution 2: Add protected constructors in
Resource/ProxyResourcePros
Cons
Solution 3: Shadowing
id,name, etc... in child classes, similar to #2639Pros
fromJson, sub class cannot call package-private setters on read-only properties of child class that's in a different package #2741Cons
Solution 4: Move
ProxyResourceAccessorout of implementation packagePros
Cons
Personal preference
From API's perspective, I prefer solution 3, which is the shadowing approach. It doesn't expose unnecessary APIs. Additionally, this may be consistent with the general case #2741, e.g. if the property is from parent and no public setter available, we shadow/duplicate it in child classes.
Haven't dived deep into each of the implementation. I assume all the solutions except solution 1(protected setters) involve getting some information of the base class(
Resource/ProxyResource) to determine property's access pattern.