1 20 21 package spoon.aval.support.validator; 22 23 import java.lang.annotation.Annotation ; 24 25 import spoon.aval.Validator; 26 import spoon.aval.annotation.structure.Prohibits; 27 import spoon.aval.processing.AValProcessor; 28 import spoon.aval.processing.ValidationPoint; 29 import spoon.reflect.declaration.CtAnnotation; 30 import spoon.reflect.declaration.CtElement; 31 40 public class ProhibitsValidator implements Validator<Prohibits> { 41 44 public void check(ValidationPoint<Prohibits> vp) { 45 Class <? extends Annotation > reqA = vp.getValAnnotation().value(); 46 CtElement element = vp.getProgramElement(); 47 CtAnnotation dslAnnotation = vp.getDslAnnotation(); 48 boolean valid = element.getAnnotation(reqA) ==null; 49 if (!valid) { 50 String message = vp.getValAnnotation().message().replace("?val", reqA.getCanonicalName()); 51 ValidationPoint.report(vp.getValAnnotation().severity(), dslAnnotation, message,vp.fixerFactory(vp.getValAnnotation().fixers())); 52 } 53 } 54 55 } 56 | Popular Tags |