useShortClassNames
Description
With this configuration toggle you can specify that all class names in the diagram should be generated without any package name.
If you only want to shorten the class names in fields and methods, you have to use the useShortClassNamesInFieldsAndMethods configuration option.
This feature is only available with version 2.0.0 or higher. |
Example
Here is an example from the JUnit tests using this configuration parameter:
List<String> scanPackages = new ArrayList<>();
scanPackages.add("de.elnarion.test.domain.t0025");
PlantUMLClassDiagramConfig config = new PlantUMLClassDiagramConfigBuilder(scanPackages)
.withUseShortClassNames(true).build(); (1)
PlantUMLClassDiagramGenerator generator = new PlantUMLClassDiagramGenerator(config);
String result = generator.generateDiagramText();
String expectedDiagramText = IOUtils.toString(Objects.requireNonNull(classLoader.getResource("class/0025_use_short_classnames.txt")),
StandardCharsets.UTF_8);
assertNotNull(result);
assertNotNull(expectedDiagramText);
assertEquals(expectedDiagramText.replaceAll("\\s+", ""), result.replaceAll("\\s+", ""));
which is rendered this way:
and produces this PlantUML diagram text:
@startuml
annotation AnnotationA
interface InterfaceC {
}
abstract class SuperClassC {
}
class TestClassA {
}
class TestClassB {
{field} -internalField : ClassA
}
class TestClassC {
{method} +getTestClassA ( paramTestClassB1 : TestClassB ) : TestClassA
}
SuperClassC --> InterfaceC : interfaceC
TestClassA -- AnnotationA
TestClassB "1" o-- "0..*" TestClassA : listTestClassA
TestClassC --> TestClassB : fieldTestClassB
TestClassC --|> SuperClassC
TestClassC ..|> InterfaceC
@enduml