showReturnTypes
Description
With the help of this configuration parameter it is possible to show the type of the returned objects of a method call.
The shown types are displayed according to the use short class names toggle which is activated by default.
Example
Here is an example from the JUnit tests using this configuration parameter:
// ARRANGE
PlantUMLSequenceDiagramConfigBuilder builder = new PlantUMLSequenceDiagramConfigBuilder(CallerA.class.getName(),
"callSomething").withShowReturnTypes(true); (1)
PlantUMLSequenceDiagramGenerator generator = new PlantUMLSequenceDiagramGenerator(builder.build());
String expectedDiagramText = IOUtils.toString(
Objects.requireNonNull(classLoader.getResource("sequence/0001_basic_caller_test_with_return_types.txt")),
StandardCharsets.UTF_8);
// ACT
String generatedDiagram = generator.generateDiagramText();
// ASSERT
assertAll(() -> assertNotNull(generatedDiagram), () -> assertEquals(expectedDiagramText.replaceAll("\\s+", ""),
generatedDiagram.replaceAll("\\s+", "")));
which is rendered this way:
and produces this PlantUML diagram text:
@startuml
participant CallerA
participant CallerB
activate CallerA
CallerA -> CallerB : callSomething
activate CallerB
CallerB -> CallerB : privateMethodCall
activate CallerB
CallerB --> CallerB : void
deactivate CallerB
CallerB -> CallerB : protectedMethodCall
activate CallerB
CallerB --> CallerB : void
deactivate CallerB
CallerB --> CallerA : void
deactivate CallerB
CallerA -> CallerB : callSomethingElse
activate CallerB
CallerB --> CallerA : String
deactivate CallerB
deactivate CallerA
@enduml
Without the parameter the diagram would look like this:
If used with an activated use short class names toggle it looks like this: