Advertisement
Benlahbib_Abdessamad

Untitled

Jan 7th, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.98 KB | None | 0 0
  1. helper
  2. context MM!Class def : genereConstructeurSP() : String = '\n\n'
  3. +'public ' + self.name + '() { \n\tsuper();\n' + self.ownedAttribute->iterate(elem;acc : String = '' | acc + 'this.' + elem.name + '=' + elem.initializeAttribut() + ';\n') + '} \n\n'
  4. ;
  5.  
  6. helper
  7. context MM!Class def : genereConstructeurAP() : String = '\n\n'
  8. + if self.superClass->notEmpty() then
  9. 'public ' + self.name + '(' + self.ownedAttribute->iterate(elem;acc : String = '' | acc + elem.genereType() + elem.name + ',') + (self.superClass->iterate(elem1;acc1 : String = '' | acc1 + elem1.ownedAttribute->iterate(elem;acc : String = '' | acc + elem.genereType() + elem.name + ','))).getRidOfComma() + ') {\n\tsuper(' + (self.superClass->iterate(elem1;acc1 : String = '' | acc1 + elem1.ownedAttribute->iterate(elem;acc : String = '' | acc + elem.name + ','))).getRidOfComma() + ');\n' + self.ownedAttribute->iterate(elem;acc : String = '' | acc + 'this.' + elem.name + '=' + elem.name + ';\n') + '}'
  10. else if (self .superClass->isEmpty() and self.ownedAttribute->notEmpty()) then
  11. 'public ' + self.name + '(' + (self.ownedAttribute->iterate(elem;acc : String = '' | acc + elem.genereType() + elem.name + ',')).getRidOfComma() + '){\n\t' + self.ownedAttribute->iterate(elem;acc : String = '' | acc + 'this.' + elem.name + '=' + elem.name + ';\n') + '}'
  12. else
  13. ''
  14. endif
  15. endif
  16.  
  17. ;
  18.  
  19.  
  20. helper
  21. context MM!Property def : initializeAttribut() : String = ''
  22. + if self.genereType() = 'Double ' then
  23. '0.0'
  24. else if self.genereType() = 'Object ' then
  25. 'null'
  26. else if self.genereType() = 'Integer ' then
  27. '0'
  28. else if self.genereType() = 'String ' then
  29. '\"\"'
  30. else
  31. 'null'
  32. endif
  33. endif
  34. endif
  35. endif
  36. ;
  37.  
  38.  
  39. helper
  40. context String def : getRidOfComma() : String = ''
  41. +self.substring(1,self.size()-1)
  42. ;
  43.  
  44. helper
  45. context MM!Property def : genereType() : String =
  46. if self.type.oclIsUndefined() then
  47. 'Object '
  48. else if self.type.name = 'Real' then
  49. 'Double '
  50. else
  51. self.type.name + ' '
  52. endif
  53. endif
  54. ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement