class entities keywords request: metaclass and stereotype

+1 vote
asked Oct 17, 2022 in Wanted features by grivo (240 points)

can some class specific keywords to be added for class diagrams

it would be nice having metaclass and stereotype keywords

also - auto-chars M and S (respectively) would be great

metaclass X {}

stereotype Y {}

2 Answers

0 votes
answered Oct 17, 2022 by The-Lu (64,340 points)

Hello G., and all,

The main question is how many new keywords will be necessary for the future.
See recent Wanted feature or PR (for Protocol, Struct or Exception):


Perhaps the best solution will be to manage a more generic solution possible used by the user, without create new keywords on PlantUML.


Then, here is a temporary proposal using procedure, as:

@startuml

!procedure metaclass($name) 
class $name << (M,#FF7700) Metaclass >> 
!endprocedure

!procedure stereotype($name) 
class $name << S,#FF77FF) Stereotype >> 
!endprocedure

class MyMetaClass <<metaclass>>

class MyStereotype <<stereotype>> {
    + x : int = 8879797
    - qwert() : int
}

metaclass(MyMetaClass2) {
    + x : int = 8879797
    - qwert() : int
}

stereotype(MyStereotype2) {
    + x : int = 8879797
    - qwert() : int
}
@enduml

If that can help,
Regards.

commented Oct 17, 2022 by grivo (240 points)

Sure, procedure ad-hoc makes sense, however, metaclass and stereotype are UML2 core entities, so PlantUML to UML2 core compliance has great value in terms of main concepts support

commented Oct 17, 2022 by The-Lu (64,340 points)

Hello G., and all,

  • Have you some ideas for the colours of the auto-char background?
metaclass colour = ?
stereotype colour = ?
Regards.
commented Oct 18, 2022 by grivo (240 points)

that looks good to me

stereotype colour = #FF77FF

metaclass colour = #CCCCCC

0 votes
answered Oct 20, 2022 by The-Lu (64,340 points)

Hello G., and all,

With last snapshot, you can now use:

@startuml
metaclass X {
    + x : int = 8879797
    - qwert() : int
}
stereotype Y {
    + x : int = 8879797
    - qwert() : int
}

metaclass metaclass
stereotype stereotype
@enduml


See also question here:

about auto-char 'S' of stereotype to change to «» or  ⟪⟫...

Enjoy,
Regards.

...