use of com.helger.jcodemodel.JAnnotationUse in project androidannotations by androidannotations.
the class APTCodeModelHelper method copyAnnotation.
public void copyAnnotation(IJAnnotatable annotatable, AnnotationMirror annotationMirror) {
Map<? extends ExecutableElement, ? extends AnnotationValue> parameters = annotationMirror.getElementValues();
if (!hasAnnotation(annotatable, annotationMirror)) {
AbstractJClass annotation = typeMirrorToJClass(annotationMirror.getAnnotationType());
JAnnotationUse annotate = annotatable.annotate(annotation);
for (Map.Entry<? extends ExecutableElement, ? extends AnnotationValue> param : parameters.entrySet()) {
param.getValue().accept(new AnnotationParamExtractor(annotate, this), param.getKey().getSimpleName().toString());
}
}
}
use of com.helger.jcodemodel.JAnnotationUse in project adt4j by sviperll.
the class Stage0ValueClassModelFactory method createStage0Model.
public Stage0ValueClassModel createStage0Model(JDefinedClass bootModel, Visitor visitorAnnotation) {
GenerationProcess generation = new GenerationProcess();
JAnnotationUse annotation = null;
for (JAnnotationUse anyAnnotation : bootModel.annotations()) {
AbstractJClass annotationClass = anyAnnotation.getAnnotationClass();
if (!annotationClass.isError()) {
String fullName = annotationClass.fullName();
if (fullName != null && fullName.equals(GenerateValueClassForVisitor.class.getName()))
annotation = anyAnnotation;
}
}
if (annotation == null)
throw new IllegalStateException("ValueClassModelFactory can't be run for interface without " + GenerateValueClassForVisitor.class + " annotation");
VisitorDefinition visitorModel = generation.processGenerationResult(VisitorDefinition.createInstance(bootModel, visitorAnnotation));
ValueClassConfiguration configuration = generation.processGenerationResult(ValueClassConfiguration.createInstance(visitorModel, annotation));
int mods = configuration.isValueClassPublic() ? JMod.PUBLIC : JMod.NONE;
JDefinedClass valueClass;
try {
valueClass = factory.defineClass(bootModel._package().name(), mods, configuration.valueClassName());
} catch (JClassAlreadyExistsException ex) {
return new Stage0ValueClassModel("Class " + configuration.valueClassName() + " already exists");
}
JAnnotationUse generatedAnnotation = valueClass.annotate(Generated.class);
generatedAnnotation.param("value", GenerateValueClassForVisitorProcessor.class.getName());
Source.annotateParametersAreNonnullByDefault(valueClass);
return new Stage0ValueClassModel(valueClass);
}
use of com.helger.jcodemodel.JAnnotationUse in project adt4j by sviperll.
the class FieldReader method readGetter.
GenerationResult<Void> readGetter(MethodUsage interfaceMethod, VariableDeclaration param, AbstractJType paramType, boolean isVarArg) {
GenerationProcess generation = new GenerationProcess();
for (JAnnotationUse annotationUsage : param.annotations()) {
AbstractJClass annotationClass = annotationUsage.getAnnotationClass();
if (!annotationClass.isError()) {
String annotationClassName = annotationClass.fullName();
if (annotationClassName != null && annotationClassName.equals(Getter.class.getName())) {
String getterName = annotationUsage.getParam("name", String.class);
if (getterName == null || getterName.equals(":auto"))
getterName = param.name();
MemberAccess accessLevel = annotationUsage.getParam("access", MemberAccess.class);
boolean isNullable = Source.isNullable(param);
FieldFlags flags = new FieldFlags(isNullable, isVarArg, accessLevel);
FieldConfiguration configuration = new FieldConfiguration(getterName, paramType, flags);
generation.processGenerationResult(read(interfaceMethod, param, configuration));
}
}
}
return generation.<Void>createGenerationResult(null);
}
use of com.helger.jcodemodel.JAnnotationUse in project adt4j by sviperll.
the class PredicatesReader method read.
GenerationResult<Void> read(JMethod interfaceMethod, JAnnotationUse annotationUsage) {
GenerationProcess generation = new GenerationProcess();
String annotationClassName = annotationUsage.getAnnotationClass().fullName();
if (annotationClassName != null) {
if (annotationClassName.equals(GeneratePredicate.class.getName())) {
String predicateName = annotationUsage.getParam("name", String.class);
MemberAccess accessLevel = annotationUsage.getParam("access", MemberAccess.class);
generation.processGenerationResult(read(interfaceMethod, predicateName, accessLevel));
} else if (annotationClassName.equals(GeneratePredicates.class.getName())) {
JAnnotationUse[] annotations = annotationUsage.getParam("value", JAnnotationUse[].class);
if (annotations != null) {
for (JAnnotationUse annotation : annotations) {
generation.processGenerationResult(read(interfaceMethod, annotation));
}
}
}
}
return generation.createGenerationResult(null);
}
use of com.helger.jcodemodel.JAnnotationUse in project adt4j by sviperll.
the class ValueClassConfiguration method getPredicates.
public GenerationResult<Map<String, PredicateConfigutation>> getPredicates() {
GenerationProcess generation = new GenerationProcess();
Map<String, PredicateConfigutation> predicates = new TreeMap<>();
PredicatesReader predicatesReader = new PredicatesReader(predicates);
for (JMethod interfaceMethod : visitorDefinition.methodDefinitions()) {
for (JAnnotationUse annotationUsage : interfaceMethod.annotations()) {
generation.processGenerationResult(predicatesReader.read(interfaceMethod, annotationUsage));
}
}
return generation.createGenerationResult(predicates);
}
Aggregations