methodBlacklistRegexp
Description
With this configuration option you can add a regular expression to the configuration to filter out specific methods from the diagram.
Example
Here is an example from the JUnit tests using this configuration parameter:
String filename = "class/0017_blacklist_methods.txt";
classLoader.loadClass("de.elnarion.test.domain.t0017.Testclass1");
List<String> scanPackages = new ArrayList<>();
scanPackages.add("de.elnarion.test.domain.t0017");
PlantUMLClassDiagramConfig config = new PlantUMLClassDiagramConfigBuilder(scanPackages)
.withMethodBlacklistRegexp(".*doSomething1.*").build(); (1)
PlantUMLClassDiagramGenerator generator = new PlantUMLClassDiagramGenerator(config);
String result = generator.generateDiagramText();
String expectedDiagramText = IOUtils.toString(Objects.requireNonNull(classLoader.getResource(filename)), StandardCharsets.UTF_8);
assertNotNull(result);
assertNotNull(expectedDiagramText);
assertEquals(expectedDiagramText.replaceAll("\\s+", ""), result.replaceAll("\\s+", ""));
String filename = "class/0017_blacklist_methods_empty_parameter.txt";
classLoader.loadClass("de.elnarion.test.domain.t0017.Testclass1");
List<String> scanPackages = new ArrayList<>();
scanPackages.add("de.elnarion.test.domain.t0017");
PlantUMLClassDiagramConfig config = new PlantUMLClassDiagramConfigBuilder(scanPackages)
.withMethodBlacklistRegexp("").build(); (1)
PlantUMLClassDiagramGenerator generator = new PlantUMLClassDiagramGenerator(config);
String result = generator.generateDiagramText();
String expectedDiagramText = IOUtils.toString(Objects.requireNonNull(classLoader.getResource(filename)), 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
class de.elnarion.test.domain.t0017.Testclass1 {
{field} +testfield : long
}
class de.elnarion.test.domain.t0017.Testclass2 {
{method} #doSomething () : void
}
de.elnarion.test.domain.t0017.Testclass1 --> de.elnarion.test.domain.t0017.Testclass2 : testfield2
@enduml