Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Howto: Register Annotation Constraints

Revision as of 02:34, 30 August 2008 by Unnamed Poltroon (Talk) (New page: __TOC__ {{backlink|Tigerstripe_APIs}} Annotation Framework support annotation creation constraints. To define custom constraint you need to create constraint class: public class Annota...)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

< To: Tigerstripe_APIs

Annotation Framework support annotation creation constraints. To define custom constraint you need to create constraint class:

 public class AnnotationConstraintExample implements IAnnotationConstraint {
   public IStatus validate(IAnnotationValidationContext context) {
     Annotation annotation = context.getAnnotation();
     URI uri = annotation.getUri();
     if (...)
       return context.createFailureStatus(...);
     return context.createSuccessStatus();
   }
 }

This constraint should implements IAnnotationConstraint interface. You can use IAnnotationValidationContext to get annotation context and to create result status. The last step is register constraint using org.eclipse.tigerstripe.annotation.core.constraints extension point:

 <extension
     point="org.eclipse.tigerstripe.annotation.core.constraints">
   <constraint
       class="org.eclipse.tigerstripe.annotation.example.AnnotationConstraintExample"/>
 </extension>

Back to the top