useShortClassNamesInFieldsAndMethods
Description
With this configuration toggle you can specify that all class names in internal fields or method parameters or method return types in the diagram should be generated without any package name.
If you want to shorten the class names at all, you have to use the useShortClassNames 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)
.withUseShortClassNamesInFieldsAndMethods(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_in_fields_and_methods.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 de.elnarion.test.domain.t0025.AnnotationA
interface de.elnarion.test.domain.t0025.InterfaceC {
}
abstract class de.elnarion.test.domain.t0025.SuperClassC {
}
class de.elnarion.test.domain.t0025.TestClassA {
}
class de.elnarion.test.domain.t0025.TestClassB {
{field} -internalField : ClassA
}
class de.elnarion.test.domain.t0025.TestClassC {
{method} +getTestClassA ( paramTestClassB1 : TestClassB ) : TestClassA
}
de.elnarion.test.domain.t0025.SuperClassC --> de.elnarion.test.domain.t0025.InterfaceC : interfaceC
de.elnarion.test.domain.t0025.TestClassA -- de.elnarion.test.domain.t0025.AnnotationA
de.elnarion.test.domain.t0025.TestClassB "1" o-- "0..*" de.elnarion.test.domain.t0025.TestClassA : listTestClassA
de.elnarion.test.domain.t0025.TestClassC --> de.elnarion.test.domain.t0025.TestClassB : fieldTestClassB
de.elnarion.test.domain.t0025.TestClassC --|> de.elnarion.test.domain.t0025.SuperClassC
de.elnarion.test.domain.t0025.TestClassC ..|> de.elnarion.test.domain.t0025.InterfaceC
@enduml