maxVisibilityFields

Description

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

The following options are supported:

  • PUBLIC
    only public fields will be displayed

  • PROTECTED
    only public and protected fields will be displayed

  • PACKAGE_PRIVATE
    only public, protected and package_private fields 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/0013_max_visibility_fields_public.txt";
List<String> scanPackages = new ArrayList<>();
scanPackages.add("de.elnarion.test.domain.t0013");
PlantUMLClassDiagramConfig config = new PlantUMLClassDiagramConfigBuilder(scanPackages)
        .withMaximumFieldVisibility(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 fields to public in the configuration

which is rendered this way:

0013_max_visibility_fields_public_diagram

and produces this PlantUML diagram text:

@startuml

class de.elnarion.test.domain.t0013.Testclass {
	{field} +test4 : long
	{field} +test5 : long
}

@enduml

Maximum visibility protected

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

config = new PlantUMLClassDiagramConfigBuilder(scanPackages)
        .withMaximumFieldVisibility(VisibilityType.PROTECTED).build(); (1)
generator = new PlantUMLClassDiagramGenerator(config);
result = generator.generateDiagramText();
filename = "class/0013_max_visibility_fields_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 fields to protected in the configuration

which is rendered this way:

0013_max_visibility_fields_protected_diagram

and produces this PlantUML diagram text:

@startuml

class de.elnarion.test.domain.t0013.Testclass {
	{field} #test3 : long
	{field} +test4 : long
	{field} +test5 : long
}

@enduml

Maximum visibility package private

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

config = new PlantUMLClassDiagramConfigBuilder(scanPackages)
        .withMaximumFieldVisibility(VisibilityType.PACKAGE_PRIVATE).build(); (1)
generator = new PlantUMLClassDiagramGenerator(config);
result = generator.generateDiagramText();
filename = "class/0013_max_visibility_fields_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 fields to package private in the configuration

which is rendered this way:

0013_max_visibility_fields_package_private_diagram

and produces this PlantUML diagram text:

@startuml

class de.elnarion.test.domain.t0013.Testclass {
	{field} ~test2 : long
	{field} #test3 : long
	{field} +test4 : long
	{field} +test5 : long
}

@enduml

Maximum visibility private

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

config = new PlantUMLClassDiagramConfigBuilder(scanPackages).withMaximumFieldVisibility(VisibilityType.PRIVATE)
        .build(); (1)
generator = new PlantUMLClassDiagramGenerator(config);
result = generator.generateDiagramText();
filename = "class/0013_max_visibility_fields_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 fields to private in the configuration

which is rendered this way:

0013_max_visibility_fields_private_diagram

and produces this PlantUML diagram text:

@startuml

class de.elnarion.test.domain.t0013.Testclass {
	{field} -test1 : long
	{field} ~test2 : long
	{field} #test3 : long
	{field} +test4 : long
	{field} +test5 : long
}

@enduml