Add alias for existing object?

0 votes
asked Feb 21 in Question / help by Nicolas (120 points)

Hey there, is it possible to add an alias for an existing object?

My use case is for a class diagram, if this matters:

class classA <<(C,SomeColor)>> #SomeColor
class classB <<(C,OtherColor)>> #OtherColor

!if (somecondition)
    ' set alias "c" for classA
!else
    ' set alias "c" for classB
!endif

c --> something1
c --> something2

So the sense is to use the alias name throughout the uml file. Via switch, the class object behind the alias should be a different one.

1 Answer

+1 vote
answered Sep 5 by kirchsth (6,320 points)

Hi @Nicolas,

you could use a variable instead of an alias

@startuml
class classA<<(C,#green)>> #lightgreen
class classB<<(C,#blue)>> #lightblue

!if (somecondition)
  !$finalAlias = classA
!else
  !$finalAlias = classAB
!endif

$finalAlias --> something1
$finalAlias --> something2
@enduml

 

BR Helmut

...