KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > spoon > aval > annotations > jwsValImpl > ValidEndPointInterfaceValidator


1 package spoon.aval.annotations.jwsValImpl;
2
3 import spoon.aval.Validator;
4 import spoon.aval.annotations.jwsVal.ValidEndPointInterface;
5 import spoon.aval.processing.ValidationPoint;
6 import spoon.processing.Severity;
7 import spoon.reflect.declaration.CtInterface;
8 import spoon.reflect.declaration.ModifierKind;
9
10 public class ValidEndPointInterfaceValidator implements
11         Validator<ValidEndPointInterface> {
12
13     public void check(ValidationPoint<ValidEndPointInterface> vp) {
14         if (vp.getProgramElement() instanceof CtInterface) {
15             CtInterface<?> endPointItf = (CtInterface<?>) vp
16                     .getProgramElement();
17
18             boolean isPublic = endPointItf.hasModifier(ModifierKind.PUBLIC);
19             boolean definesEndPoint = vp.getDslAnnotation().getElementValue(
20                     "endPointInterface").equals("");
21             boolean definesServiceName = vp.getDslAnnotation().getElementValue(
22                     "serviceName").equals("");
23
24             if (!isPublic) {
25                 ValidationPoint.report(Severity.ERROR, endPointItf,
26                         "An EndPointInterface must be public");
27             }
28
29             if (definesEndPoint) {
30                 ValidationPoint
31                         .report(Severity.ERROR, vp.getDslAnnotation(),
32                                 "An EndPointInterface cannot define the attribute \'endPointInterface\'");
33             }
34
35             if (definesServiceName) {
36                 ValidationPoint
37                         .report(Severity.ERROR, vp.getDslAnnotation(),
38                                 "An EndPointInterface cannot define the attribute \'serviceName\'");
39             }
40         }
41     }
42
43 }
44
Popular Tags