Skip to content

Commit de4ffaa

Browse files
Added few printOn methods
1 parent 62a2277 commit de4ffaa

File tree

4 files changed

+61
-0
lines changed

4 files changed

+61
-0
lines changed

repository/OP-UML-Metamodel/OPUMLAssociation.class.st

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,29 @@ OPUMLAssociation >> powertypeExtents: aGeneralizationSet [
373373
(sharedGeneralizations at: #Classifier) powertypeExtents: aGeneralizationSet
374374
]
375375

376+
{ #category : 'printing' }
377+
OPUMLAssociation >> printOn: aStream [
378+
379+
| ends |
380+
aStream << 'an ' << self class name << '('.
381+
self name ifNotNil: [ :existingName |
382+
existingName ifNotEmpty: [
383+
existingName printOn: aStream.
384+
aStream << ': ' ] ].
385+
ends := self memberEnds asOrderedCollection.
386+
ends addAll: self ownedEnds.
387+
ends
388+
ifEmpty: [ aStream << 'nil -> nil' ]
389+
ifNotEmpty: [ :properties |
390+
properties
391+
do: [ :each |
392+
each type
393+
ifNil: [ aStream << 'nil' ]
394+
ifNotNil: [ :type | type printAsClassifierNameOn: aStream ] ]
395+
separatedBy: [ aStream << ' -> ' ] ].
396+
aStream << ')'
397+
]
398+
376399
{ #category : 'accessing - NamedElement' }
377400
OPUMLAssociation >> qualifiedName [
378401
^ (sharedGeneralizations at: #NamedElement) qualifiedName

repository/OP-UML-Metamodel/OPUMLGeneralization.class.st

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,21 @@ OPUMLGeneralization >> isSubstitutable: aBoolean [
6767
isSubstitutable := aBoolean
6868
]
6969

70+
{ #category : 'printing' }
71+
OPUMLGeneralization >> printOn: aStream [
72+
73+
super printOn: aStream.
74+
aStream << '('.
75+
self specific
76+
ifNil: [ aStream << 'nil' ]
77+
ifNotNil: [ :element | element printAsClassifierNameOn: aStream ].
78+
aStream << ' -> '.
79+
self general
80+
ifNil: [ aStream << 'nil' ]
81+
ifNotNil: [ :element | element printAsClassifierNameOn: aStream ].
82+
aStream << ')'
83+
]
84+
7085
{ #category : 'accessing - Relationship' }
7186
OPUMLGeneralization >> relatedElements [
7287
^ (sharedGeneralizations at: #Relationship) relatedElements

repository/OP-UML-Metamodel/OPUMLMetaElement.class.st

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,17 @@ OPUMLMetaElement >> oclIsTypeOf: aClassifier [
264264
^ sharedGeneralizations keys last = (self oclClassifierNameFrom: aClassifier)
265265
]
266266

267+
{ #category : 'printing' }
268+
OPUMLMetaElement >> printAsClassifierNameOn: aStream [
269+
270+
aStream << (self oclClassifierNameFrom: self class).
271+
(self class selectors includes: #name) ifTrue: [
272+
aStream
273+
<< '(';
274+
<< self name printString;
275+
<< ')' ]
276+
]
277+
267278
{ #category : 'printing' }
268279
OPUMLMetaElement >> printOn: aStream [
269280
super printOn: aStream.

repository/OP-UML-Metamodel/OPUMLProperty.class.st

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,18 @@ OPUMLProperty >> owningTemplateParameter: aTemplateParameter [
496496
(sharedGeneralizations at: #ParameterableElement) owningTemplateParameter: aTemplateParameter
497497
]
498498

499+
{ #category : 'printing' }
500+
OPUMLProperty >> printOn: aStream [
501+
502+
aStream << 'an ' << self class name << '('.
503+
self name ifNotNil: [ :existingName |
504+
existingName ifNotEmpty: [
505+
aStream << existingName.
506+
self type ifNotNil: [ aStream << ': ' ] ] ].
507+
self type ifNotNil: [ :type | type printAsClassifierNameOn: aStream ].
508+
aStream << ')'
509+
]
510+
499511
{ #category : 'accessing - NamedElement' }
500512
OPUMLProperty >> qualifiedName [
501513
^ (sharedGeneralizations at: #NamedElement) qualifiedName

0 commit comments

Comments
 (0)