Skip to content

Commit

Permalink
Added few printOn methods
Browse files Browse the repository at this point in the history
  • Loading branch information
JanBliznicenko committed Nov 2, 2024
1 parent 62a2277 commit de4ffaa
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 0 deletions.
23 changes: 23 additions & 0 deletions repository/OP-UML-Metamodel/OPUMLAssociation.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,29 @@ OPUMLAssociation >> powertypeExtents: aGeneralizationSet [
(sharedGeneralizations at: #Classifier) powertypeExtents: aGeneralizationSet
]

{ #category : 'printing' }
OPUMLAssociation >> printOn: aStream [

| ends |
aStream << 'an ' << self class name << '('.
self name ifNotNil: [ :existingName |
existingName ifNotEmpty: [
existingName printOn: aStream.
aStream << ': ' ] ].
ends := self memberEnds asOrderedCollection.
ends addAll: self ownedEnds.
ends
ifEmpty: [ aStream << 'nil -> nil' ]
ifNotEmpty: [ :properties |
properties
do: [ :each |
each type
ifNil: [ aStream << 'nil' ]
ifNotNil: [ :type | type printAsClassifierNameOn: aStream ] ]
separatedBy: [ aStream << ' -> ' ] ].
aStream << ')'
]

{ #category : 'accessing - NamedElement' }
OPUMLAssociation >> qualifiedName [
^ (sharedGeneralizations at: #NamedElement) qualifiedName
Expand Down
15 changes: 15 additions & 0 deletions repository/OP-UML-Metamodel/OPUMLGeneralization.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,21 @@ OPUMLGeneralization >> isSubstitutable: aBoolean [
isSubstitutable := aBoolean
]

{ #category : 'printing' }
OPUMLGeneralization >> printOn: aStream [

super printOn: aStream.
aStream << '('.
self specific
ifNil: [ aStream << 'nil' ]
ifNotNil: [ :element | element printAsClassifierNameOn: aStream ].
aStream << ' -> '.
self general
ifNil: [ aStream << 'nil' ]
ifNotNil: [ :element | element printAsClassifierNameOn: aStream ].
aStream << ')'
]

{ #category : 'accessing - Relationship' }
OPUMLGeneralization >> relatedElements [
^ (sharedGeneralizations at: #Relationship) relatedElements
Expand Down
11 changes: 11 additions & 0 deletions repository/OP-UML-Metamodel/OPUMLMetaElement.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,17 @@ OPUMLMetaElement >> oclIsTypeOf: aClassifier [
^ sharedGeneralizations keys last = (self oclClassifierNameFrom: aClassifier)
]

{ #category : 'printing' }
OPUMLMetaElement >> printAsClassifierNameOn: aStream [

aStream << (self oclClassifierNameFrom: self class).
(self class selectors includes: #name) ifTrue: [
aStream
<< '(';
<< self name printString;
<< ')' ]
]

{ #category : 'printing' }
OPUMLMetaElement >> printOn: aStream [
super printOn: aStream.
Expand Down
12 changes: 12 additions & 0 deletions repository/OP-UML-Metamodel/OPUMLProperty.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,18 @@ OPUMLProperty >> owningTemplateParameter: aTemplateParameter [
(sharedGeneralizations at: #ParameterableElement) owningTemplateParameter: aTemplateParameter
]

{ #category : 'printing' }
OPUMLProperty >> printOn: aStream [

aStream << 'an ' << self class name << '('.
self name ifNotNil: [ :existingName |
existingName ifNotEmpty: [
aStream << existingName.
self type ifNotNil: [ aStream << ': ' ] ] ].
self type ifNotNil: [ :type | type printAsClassifierNameOn: aStream ].
aStream << ')'
]

{ #category : 'accessing - NamedElement' }
OPUMLProperty >> qualifiedName [
^ (sharedGeneralizations at: #NamedElement) qualifiedName
Expand Down

0 comments on commit de4ffaa

Please sign in to comment.