Wednesday 26 July 2023

PlantUML: Hide unlinked classes, interfaces in a class diagram

'hide @unlinked' command hide unlinked classed, interfaces, enums in a class diagram.

 

For example, let’s see the below snippet.

 

demoDiag.txt

@startuml

class Set{}
interface Cloneable{}
enum TimeUnit{
	Days
	Hours
	Minutes
	Seconds
}

interface Serializable <<Marker>>{}
abstract class AbstractList <<Serializable>> {}

class Employee <<Serializable>>{
	int id
	String name
	int age

	String aboutMe()
}

class Manager <<Serializable>>{
	int noOfReportees
}

Serializable <|.. Employee
Employee <|-- Manager

@enduml

 

Above snippet generate below diagram.

As you see above snippet following are the unlinked entities.

a.   Set

b.   Cloneable

c.    TimeUnit

d.   AbstractList

 

Let’s hide them using ‘hide @unlinked’ command.

 

hideUnlinked.txt 

@startuml

hide @unlinked

class Set{}
interface Cloneable{}
enum TimeUnit{
	Days
	Hours
	Minutes
	Seconds
}

interface Serializable <<Marker>>{}
abstract class AbstractList <<Serializable>> {}

class Employee <<Serializable>>{
	int id
	String name
	int age

	String aboutMe()
}

class Manager <<Serializable>>{
	int noOfReportees
}

Serializable <|.. Employee
Employee <|-- Manager

@enduml

 

Above snippet generate below diagram.


 


 

Previous                                                    Next                                                    Home

No comments:

Post a Comment