1 19 20 package org.netbeans.modules.j2ee.jpa.verification; 21 22 import java.util.Collection ; 23 import javax.lang.model.element.TypeElement; 24 import org.netbeans.modules.j2ee.jpa.verification.common.ProblemContext; 25 import org.netbeans.modules.j2ee.jpa.verification.common.Rule; 26 27 31 public abstract class JPAClassRule extends Rule<TypeElement> { 32 public enum ClassConstraints {ENTITY, EMBEDDABLE, IDCLASS, MAPPED_SUPERCLASS} 33 private Collection <ClassConstraints> classContraints; 34 35 protected void setClassContraints(Collection <ClassConstraints> classContraints){ 36 this.classContraints = classContraints; 37 } 38 39 @Override protected boolean isApplicable(TypeElement subject, ProblemContext ctx) { 40 JPAProblemContext jpaCtx = (JPAProblemContext)ctx; 41 42 if (classContraints != null && !( 43 jpaCtx.isEntity() && classContraints.contains(ClassConstraints.ENTITY) 44 || jpaCtx.isEmbeddable() && classContraints.contains(ClassConstraints.EMBEDDABLE) 45 || jpaCtx.isMappedSuperClass() && classContraints.contains(ClassConstraints.MAPPED_SUPERCLASS) 46 || jpaCtx.isIdClass() && classContraints.contains(ClassConstraints.IDCLASS))){ 47 return false; 48 } 49 50 return super.isApplicable(subject, ctx); 51 } 52 } 53 | Popular Tags |