[MDSAL-151] Add "add"/"del" utility methods to builders. Created: 05/Apr/16 Updated: 13/Sep/18 Resolved: 13/Sep/18 |
|
| Status: | Resolved |
| Project: | mdsal |
| Component/s: | Binding V2 codegen |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Improvement | ||
| Reporter: | Sharon Aicler | Assignee: | Jie Han |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Operating System: All |
||
| Description |
|
It will make it much easier to work with List properties if in addition to setter & getter we can add "adder" & "remover" of elements, e.g. if the property type is List<Node> and today we have "void setNode(List<Node> node)" & "List<Node> getNodes()", we should add also "void addNode(Node node)" and "delNode(Node node)" to make it easy to use. |
| Comments |
| Comment by Dhevendran Kulandaivel [ 17/May/16 ] |
|
(In reply to Sharon Aicler from comment #0) Hi Sharon Aicler I can take up this . Can you provide us more details on this requirement Thanks & Regards, |
| Comment by Sharon Aicler [ 18/May/16 ] |
|
Hi Dhevendran, Today the generated method inside MyContainer builder will be: public List<MyList> getMyKList(){ return impl.myList; } I am suggesting add helper methods of "add" and "del" public void setMyList(List<MyList> lst){ impl.myList = lst; } public List<MyList> getMyKList() { return impl.myList; } public void addMyList(MyList element){ this.impl.myList.add(element); So bottom line a developer should not instantiate a list every time and allow the builder to do it. |
| Comment by Dhevendran Kulandaivel [ 25/May/16 ] |
|
H Sharon Aicler Thanks for your input. I will get back to you on this Thanks & Regards, |
| Comment by Alaykumar B Patel [ 28/Dec/16 ] |
|
Hey Sharon, I think one can add the method signatures to ChildOf node in listToGenType method, and then in the BaseTemplate.xtend define methods to generate adder and remover methods by getting the method signatures through type.getMethodSignatures() in BaseTemplate. Is this a natural way of achieving it? Thank you Regards, |
| Comment by Jie Han [ 07/Feb/18 ] |