maxVisibilityMethods

Description

With this configuration option you can filter out methods from the diagram by their visibility in Java.

The following options are supported:

  • PUBLIC
    only public methods will be displayed

  • PROTECTED
    only public and protected methods will be displayed

  • PACKAGE_PRIVATE
    only public, protected and package_private methods will be displayed

  • PRIVATE
    all fields will be displayed if not removed or ignored by other parameters

Default value

The default value of this configuration option is PRIVATE.

Example

Maximum visibility public

Here is an example from the JUnit tests using this configuration parameter:

String filename = "class/0014_max_visibility_methods_public.txt";
classLoader.loadClass("de.elnarion.test.domain.t0014.Testclass");
List<String> scanPackages = new ArrayList<>();
scanPackages.add("de.elnarion.test.domain.t0014");
PlantUMLClassDiagramConfig config = new PlantUMLClassDiagramConfigBuilder(scanPackages)
        .withMaximumMethodVisibility(VisibilityType.PUBLIC).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+", ""));
1 set maximum visibility for methods to public in the configuration

which is rendered this way:

0013_max_visibility_methods_public_diagram

and produces this PlantUML diagram text:

@startuml

class de.elnarion.test.domain.t0014.Testclass {
	{method} +doSomething4() : void
}

@enduml

Maximum visibility protected

Here is an example from the JUnit tests using this configuration parameter:

config = new PlantUMLClassDiagramConfigBuilder(scanPackages)
        .withMaximumMethodVisibility(VisibilityType.PROTECTED).build(); (1)
generator = new PlantUMLClassDiagramGenerator(config);
result = generator.generateDiagramText();
filename = "class/0014_max_visibility_methods_protected.txt";
expectedDiagramText = IOUtils.toString(Objects.requireNonNull(classLoader.getResource(filename)), StandardCharsets.UTF_8);
assertNotNull(result);
assertNotNull(expectedDiagramText);
assertEquals(expectedDiagramText.replaceAll("\\s+", ""), result.replaceAll("\\s+", ""));
1 set maximum visibility for methods to protected in the configuration

which is rendered this way:

0013_max_visibility_methods_protected_diagram

and produces this PlantUML diagram text:

@startuml

class de.elnarion.test.domain.t0014.Testclass {
	{method} #doSomething3() : void
	{method} +doSomething4() : void
}

@enduml

Maximum visibility package private

Here is an example from the JUnit tests using this configuration parameter:

config = new PlantUMLClassDiagramConfigBuilder(scanPackages)
        .withMaximumMethodVisibility(VisibilityType.PACKAGE_PRIVATE).build(); (1)
generator = new PlantUMLClassDiagramGenerator(config);
result = generator.generateDiagramText();
filename = "class/0014_max_visibility_methods_package_private.txt";
expectedDiagramText = IOUtils.toString(Objects.requireNonNull(classLoader.getResource(filename)), StandardCharsets.UTF_8);
assertNotNull(result);
assertNotNull(expectedDiagramText);
assertEquals(expectedDiagramText.replaceAll("\\s+", ""), result.replaceAll("\\s+", ""));
1 set maximum visibility for methods to package private in the configuration

which is rendered this way:

0013_max_visibility_methods_package_private_diagram

and produces this PlantUML diagram text:

@startuml

class de.elnarion.test.domain.t0014.Testclass {
	{method} ~doSomething2() : void
	{method} #doSomething3() : void
	{method} +doSomething4() : void
}

@enduml

Maximum visibility private

Here is an example from the JUnit tests using this configuration parameter:

config = new PlantUMLClassDiagramConfigBuilder(scanPackages).withMaximumMethodVisibility(VisibilityType.PRIVATE)
        .build(); (1)
generator = new PlantUMLClassDiagramGenerator(config);
result = generator.generateDiagramText();
filename = "class/0014_max_visibility_methods_private.txt";
expectedDiagramText = IOUtils.toString(Objects.requireNonNull(classLoader.getResource(filename)), StandardCharsets.UTF_8);
assertNotNull(result);
assertNotNull(expectedDiagramText);
assertEquals(expectedDiagramText.replaceAll("\\s+", ""), result.replaceAll("\\s+", ""));
1 set maximum visibility for methods to private in the configuration

which is rendered this way:

0013_max_visibility_methods_private_diagram

and produces this PlantUML diagram text:

@startuml

class de.elnarion.test.domain.t0014.Testclass {
	{method} -doSomething1() : void
	{method} ~doSomething2() : void
	{method} #doSomething3() : void
	{method} +doSomething4() : void
}

@enduml