Friday 28 July 2023

PlantUML: remove unlinked classes, interfaces in a class diagram

'remove @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 remove them using ‘remove @unlinked’ command.

 

removeUnlinked.txt

@startuml

remove @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