Sunday, 18 June 2023

PlantUML: define static method in a class diagram

Static methods are defined using {static} modifier.

 

Example

+{static} Double valueOf(String s)

 

+ represent the access specifier public.

 

staticMethods.txt

@startuml

class Double{

	' public static fields
	+{static} double POSITIVE_INFINITY = 1.0 / 0.0
	+{static} double NEGATIVE_INFINITY = -1.0 / 0.0
	+{static} double NaN = 0.0d / 0.0
	+{static} double MAX_VALUE = 0x1.fffffffffffffP+1023
	+{static} double MIN_NORMAL = 0x1.0p-1022
	+{static} double MIN_VALUE = 0x0.0000000000001P-1022

	' private instace fields
	-double value

	' public static method
	+{static} Double valueOf(String s)
	+{static} boolean isNaN(double v)
	+{static} boolean isFinite(double d)
	+{static} boolean isInfinite(double v)

	' public instance methods
	+boolean isInfinite()
	+String toString()
}

@enduml

 

Above snippet generate below diagram.


 

 

 

Previous                                                    Next                                                    Home

No comments:

Post a Comment