-
Notifications
You must be signed in to change notification settings - Fork 7
Model verification
This document describes the usage of annotation processing for model verification. The verifying processor assists the developer with spotting incorrect model definitions by printing informative messages in the editor. Similar to a compiler that signals errors upon encountering illegal syntax, the verifying processor analyses the source code, but with a greater focus on semantics.
The verifying processor is packaged together with the meta-model processor, so
the inital setup steps are identical to those described in MetaModels.
To enable the verifying processor make sure to configure the maven-compiler-plugin
in the pom.xml
of the respective *-pojo-bl
project:
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<encoding>UTF-8</encoding>
<!-- to enable output of annotation processors -->
<showWarnings>true</showWarnings>
<generatedSourcesDirectory>${project.build.directory}/generated-sources/</generatedSourcesDirectory>
<annotationProcessorPaths>
<annotationProcessorPath>
<groupId>fielden</groupId>
<artifactId>platform-annotation-processors</artifactId>
<version>${platform.version}</version>
</annotationProcessorPath>
</annotationProcessorPaths>
<annotationProcessors>
<annotationProcessor>
ua.com.fielden.platform.processors.verify.VerifyingProcessor
</annotationProcessor>
<!-- YOUR OTHER PROCESSORS -->
</annotationProcessors>
</configuration>
</plugin>
</plugins>
For convenience it is recommended to configure a separate View window for messages reported by the verifier.
-
Create a new Problems View. In this example it's named "APT".
-
Configure filters for the new problems view to only display messages produced by annotation processors.
-
Configure filters for the original problems view to exclude messages produced by annotation processors.
In some cases it might be desirable to relax the verification,
i.e., reduce the severity of reported messsages. For example,
to ask the verifying processor to report a warning instead of an error.
For this purpose the @RelaxVerification
annotation can be used.
Examples follow.
- Report a warning instead of an error.
@RelaxVerification
@IsProperty
private int number; // Warning: int is an unsupported property type
- Report an info instead of an error.
@RelaxVerification(RelaxationPolicy.INFO)
@IsProperty
private int number; // Info: int is an unsupported property type
- Apply the effect to the annotated element and to all elements enclosed by it.
@RelaxVerification
@EntityTitle("Example entity")
// Warning: Entity is missing @KeyType
public class ExampleEntity extends AbstractEntity<String> {
@IsProperty
private int number; // Warning: int is an unsupported property type
}
- Apply the effect only to the annotated element.
@RelaxVerification(enclosed = false) // by default enclosed = true
@EntityTitle("Example entity")
// Warning: Entity is missing @KeyType
public class ExampleEntity extends AbstractEntity<String> {
@IsProperty
private int number; // ERROR: int is an unsupported property type
}
It's also possible to ask the processor to skip the verification of an element
entirely by using the @SkipVerification
annotation. Unlike
@RelaxVerification
, the effects of this one are always applied only to the
target element. Although, given the nature of this concept, skipping an element
is equivalent to excluding it from the verification process, meaning that its
enclosed elements (its contents) will be excluded too. Examples follow.
- Skip an entity element.
@SkipVerification
@EntityTitle("Example entity")
public class ExampleEntity extends AbstractEntity<String> {
@IsProperty
private int number;
}
- Skip a property element.
// ERROR: Entity is missing @KeyType
@EntityTitle("Example entity")
public class ExampleEntity extends AbstractEntity<String> {
@SkipVerification
@IsProperty
private int number;
}
Per aspera ad astra
- Web UI Design and Web API
- Safe Communication and User Authentication
- Gitworkflow
- JavaScript: Testing with Maven
- Java Application Profiling
-
TG Development Guidelines
- TLS and HAProxy for development
- TG Development Checklist
- Entity Properties
- EQL
- Tooltip How To
- All about Matchers
- Streaming data
- Synthetic entities
- Activatable entities
- Jasper Reports
- Opening Compound Master from another Compound Master
- Window management test plan
- Multi Time Zone Environment
- GraphQL Web API
- Guice
- Maven
- Full Text Search
- Deployment recipes
- JRebel Installation and Integration
- Compile-time mechanisms