Validating linkki Annotations

Unfortunately the linkki-apt cannot fully validate annotations that are part of the same module, since those annotations still have to be compiled. Yet, most of the validations still can be done.

Validations that will always work:
  • ensuring that methods being used by linkki are public

  • ensuring that positions of components are unique inside a PMO

  • ensuring that annotations of dynamic fields have the same position and are accompanied by a get<PropertyName>ComponentType method

  • ensuring that specified model bindings actually exist

    • ensure model object does exist in the PMO

    • ensure model attribute does exist in the model object

  • ensuring that bindings are explicitly specified

  • ensuring that the name of a model object is unique

Validations that only work on already compiled annotations:
  • ensuring that AvailableValuesType.ENUM_INCL_NULL or AvailableValuesType.ENUM_VALUES_EXCL_NULL are only used with Enums and booleans (relies on AvailableValuesAspectDefinition)

  • ensuring that methods required at runtime are defined (relies on the user defined LinkkiAspectDefinition)

    • (there is a distinction between abstract classes and interfaces and non-abstract classes)

Aspect related validations only work for LinkkiAspectDefinitions that are either a subclass of ModelToUiAspectDefinition or a CompositeAspectDefinition that consists only of ModelToUiAspectDefinitions. Any LinkkiAspectDefinition that is not a ModelToUiAspectDefinition will simply be excluded from validations. (For example BindReadOnly will be ignored, but BindToolTip will be validated.)

Custom Annotations

linkki-apt needs to be made aware of custom annotations created in your projects to offer validation for them.

In order to validate annotations that are not part of linkki, the classpath containing those annotations needs to be passed to the compiler as an annotation processor parameter like this:


This is required since the annotation processor needs to create an instance of the annotation, in order to validate its LinkkiAspects.

Using Maven

With Maven, you can pass the build classpath to the annotation processor with the help of the maven-dependency-plugin:

Passing the Classpath to the Annotation Processor with Maven
		<!-- builds the classpath and puts it into the property "maven.compile.classpath"-->
				<!-- arguments for annotation processor start with "-A" -->