mirror of
https://github.com/querydsl/querydsl.git
synced 2026-06-30 21:08:30 +08:00
added skip annotation handling
This commit is contained in:
parent
350e255408
commit
e9a8ef2cff
@ -30,7 +30,6 @@ import javax.tools.Diagnostic.Kind;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
import com.mysema.commons.lang.Assert;
|
||||
import com.mysema.query.annotations.Transient;
|
||||
import com.mysema.query.codegen.ClassModel;
|
||||
import com.mysema.query.codegen.ConstructorModel;
|
||||
import com.mysema.query.codegen.FieldModel;
|
||||
@ -123,7 +122,7 @@ public class Processor {
|
||||
|
||||
};
|
||||
|
||||
private final Class<? extends Annotation> entityAnn, superTypeAnn, embeddableAnn, dtoAnn;
|
||||
private final Class<? extends Annotation> entityAnn, superTypeAnn, embeddableAnn, dtoAnn, skipAnn;
|
||||
|
||||
private final ProcessingEnvironment env;
|
||||
|
||||
@ -138,12 +137,14 @@ public class Processor {
|
||||
Class<? extends Annotation> superTypeAnn,
|
||||
Class<? extends Annotation> embeddableAnn,
|
||||
Class<? extends Annotation> dtoAnn,
|
||||
Class<? extends Annotation> skipAnn,
|
||||
String namePrefix) {
|
||||
this.env = Assert.notNull(env);
|
||||
this.entityAnn = Assert.notNull(entityAnn);
|
||||
this.superTypeAnn = superTypeAnn;
|
||||
this.embeddableAnn = embeddableAnn;
|
||||
this.dtoAnn = dtoAnn;
|
||||
this.skipAnn = skipAnn;
|
||||
this.namePrefix = Assert.notNull(namePrefix);
|
||||
}
|
||||
|
||||
@ -161,14 +162,14 @@ public class Processor {
|
||||
|
||||
protected boolean isValidField(VariableElement field) {
|
||||
return useFields
|
||||
&& field.getAnnotation(Transient.class) == null
|
||||
&& field.getAnnotation(skipAnn) == null
|
||||
&& !field.getModifiers().contains(Modifier.TRANSIENT)
|
||||
&& !field.getModifiers().contains(Modifier.STATIC);
|
||||
}
|
||||
|
||||
protected boolean isValidGetter(ExecutableElement getter){
|
||||
return useGetters
|
||||
&& getter.getAnnotation(Transient.class) == null
|
||||
&& getter.getAnnotation(skipAnn) == null
|
||||
&& !getter.getModifiers().contains(Modifier.STATIC);
|
||||
}
|
||||
|
||||
|
||||
@ -16,9 +16,10 @@ import javax.lang.model.SourceVersion;
|
||||
import javax.lang.model.element.TypeElement;
|
||||
import javax.tools.Diagnostic;
|
||||
|
||||
import com.mysema.query.annotations.Projection;
|
||||
import com.mysema.query.annotations.Embeddable;
|
||||
import com.mysema.query.annotations.Entity;
|
||||
import com.mysema.query.annotations.Projection;
|
||||
import com.mysema.query.annotations.Transient;
|
||||
|
||||
|
||||
@SupportedAnnotationTypes("*")
|
||||
@ -32,7 +33,8 @@ public class QuerydslAnnotationProcessor extends AbstractProcessor{
|
||||
Class<? extends Annotation> superType = null;
|
||||
Class<? extends Annotation> embeddable = Embeddable.class;
|
||||
Class<? extends Annotation> dtoAnnotation = Projection.class;
|
||||
Processor p = new Processor(processingEnv, entity, superType, embeddable, dtoAnnotation, "Q");
|
||||
Class<? extends Annotation> skipAnnotation = Transient.class;
|
||||
Processor p = new Processor(processingEnv, entity, superType, embeddable, dtoAnnotation, skipAnnotation, "Q");
|
||||
p.process(roundEnv);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -31,7 +31,8 @@ public class JDOAnnotationProcessor extends AbstractProcessor{
|
||||
Class<? extends Annotation> superType = null; // ?!?
|
||||
Class<? extends Annotation> embeddable = (Class)Class.forName("javax.jdo.annotations.EmbeddedOnly");
|
||||
Class<? extends Annotation> dtoAnnotation = Projection.class;
|
||||
Processor p = new Processor(processingEnv, entity, superType, embeddable, dtoAnnotation, "Q");
|
||||
Class<? extends Annotation> skipAnnotation = (Class)Class.forName("javax.jdo.annotations.NotPersistent");
|
||||
Processor p = new Processor(processingEnv, entity, superType, embeddable, dtoAnnotation, skipAnnotation, "Q");
|
||||
p.skipGetters().process(roundEnv);
|
||||
return true;
|
||||
} catch (ClassNotFoundException e) {
|
||||
|
||||
@ -31,7 +31,8 @@ public class JPAAnnotationProcessor extends AbstractProcessor{
|
||||
Class<? extends Annotation> superType = (Class)Class.forName("javax.persistence.MappedSuperclass");
|
||||
Class<? extends Annotation> embeddable = (Class)Class.forName("javax.persistence.Embeddable");
|
||||
Class<? extends Annotation> dtoAnnotation = Projection.class;
|
||||
Processor p = new Processor(processingEnv, entity, superType, embeddable, dtoAnnotation, "Q");
|
||||
Class<? extends Annotation> skipAnnotation = (Class)Class.forName("javax.persistence.Transient");
|
||||
Processor p = new Processor(processingEnv, entity, superType, embeddable, dtoAnnotation, skipAnnotation, "Q");
|
||||
p.process(roundEnv);
|
||||
return true;
|
||||
} catch (ClassNotFoundException e) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user