addValidationAnnotations

Description

If you activate this configuration toggle via the builder method withValidationAnnotations the generator scans the selected classes for the following Validation Annotations:

  • field annotations

    • javax.validation.constraints.Size

    • javax.validation.constraints.NotEmpty

    • jakarta.validation.constraints.Size

    • jakarta.validation.constraints.NotEmpty

If field annotations are found the generator will adapt the cardinality of AggregationRelationship to reflect the annotation.

This feature was previously activated via the withJavaxValidationAnnotations builder method in version between 2.3.0 and 2.4.0.

Default value

The default value of this configuration toggle is false.

Example

In the following example there are three dependencies in the maven dependency hierarchy which build the classpath for all further generation:

	<dependencies>
		<dependency>
			<groupId>de.elnarion.util</groupId>
			<artifactId>plantuml-generator-util</artifactId>
			<version>@project.version@</version>
			<classifier>tests</classifier>
			<type>test-jar</type>
		</dependency>
		<dependency>
			<groupId>commons-io</groupId>
			<artifactId>commons-io</artifactId>
			<version>2.16.1</version>
		</dependency>
		<dependency>
			<groupId>javax.validation</groupId>
			<artifactId>validation-api</artifactId>
			<version>2.0.1.Final</version>
		</dependency>
	</dependencies>

From this classpath all classes of the package "de.elnarion.test.domain.t0028", which are also used by the JUnit-tests of the PlantUML generator utility, should be generated as class diagram with the following plugin configuration

			<plugin>
				<artifactId>plantuml-generator-maven-plugin</artifactId>
				<groupId>de.elnarion.maven</groupId>
				<version>@project.version@</version>
				<executions>
					<execution>
						<id>generate-simple-diagram</id>
						<goals>
							<goal>generate</goal>
						</goals>
						<phase>generate-test-sources</phase>
						<configuration>
							<outputFilename>testdiagram1.txt</outputFilename>
							<scanPackages>
								<scanPackage>de.elnarion.test.domain.t0028</scanPackage>
							</scanPackages>
							<addValidationAnnotations>true</addValidationAnnotations>
						</configuration>
					</execution>
				</executions>
			</plugin>

this configuration contains the addValidationAnnotations toggle with the value true. This configuration is rendered this way:

0028_javax_validation_annotations

and produces this PlantUML diagram text:

@startuml
class de.elnarion.test.domain.t0028.Light {
}

class de.elnarion.test.domain.t0028.Seat {
}

class de.elnarion.test.domain.t0028.Vehicle {
}

class de.elnarion.test.domain.t0028.Wheel {
}

de.elnarion.test.domain.t0028.Vehicle "1" o-- "1..*"  de.elnarion.test.domain.t0028.Light :  lights
de.elnarion.test.domain.t0028.Vehicle "1" o-- "1..10"  de.elnarion.test.domain.t0028.Seat :  seats
de.elnarion.test.domain.t0028.Vehicle "1" o-- "2..6"  de.elnarion.test.domain.t0028.Wheel :  wheels

@enduml