Thursday, 9 May 2024

PlantUML: Include files or url using !include, !include_many, !include_once directives

!include directive

We can include files in our program using !include directive. This feature is helpful in reusing the components in many diagrams.

 

For example, let’s define list.txt file.

 

list.txt

interface Collection{
	
}

interface Iterable {
	Iterator iterator()
}

interface List{
	int size()
	void clear()
	boolean add(E e)
	void add(int index, E element)
	addAll(Collection<? extends E> c)
	void clear()
	boolean contains(Object o)
}

Collection <|-- List
Iterable <|-- List

 

Let’s use the content of list.txt file in ArrayList.txt.

 

ArrayList.txt

 

@startuml

!include list.txt

class ArrayList{
	
}

List <|.. ArrayList

@enduml

 

Above snippet generate below diagram.

 


 

 

Previous                                                    Next                                                    Home

No comments:

Post a Comment