use of com.github.sviperll.adt4j.model.util.GenerationProcess 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.github.sviperll.adt4j.model.util.GenerationProcess in project adt4j by sviperll.
the class FieldReader method read.
GenerationResult<Void> read(MethodUsage interfaceMethod, VariableDeclaration param, FieldConfiguration configuration) {
GenerationProcess generation = new GenerationProcess();
FieldConfiguration existingConfiguration = fieldMap.get(configuration.name());
if (existingConfiguration == null) {
existingConfiguration = configuration;
fieldMap.put(configuration.name(), configuration);
}
try {
existingConfiguration.merge(interfaceMethod, param.name(), configuration);
} catch (FieldConfigurationException ex) {
generation.reportError(MessageFormat.format("Unable to configure {0} getter: {1}", configuration.name(), ex.getMessage()));
}
return generation.<Void>createGenerationResult(null);
}
use of com.github.sviperll.adt4j.model.util.GenerationProcess 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.github.sviperll.adt4j.model.util.GenerationProcess 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);
}
use of com.github.sviperll.adt4j.model.util.GenerationProcess in project adt4j by sviperll.
the class ValueClassConfiguration method getUpdatersConfiguration.
public GenerationResult<Map<String, FieldConfiguration>> getUpdatersConfiguration(JDefinedClass valueClass, Types types) {
GenerationProcess generation = new GenerationProcess();
AbstractJClass usedValueClassType = Source.narrowType(valueClass, valueClass.typeParams());
Map<String, FieldConfiguration> updatersMap = new TreeMap<>();
FieldReader reader = new FieldReader(updatersMap);
VisitorDefinition.VisitorUsage narrowed = visitorDefinition.narrowed(usedValueClassType, visitorDefinition.getResultTypeParameter(), types._RuntimeException);
for (MethodUsage interfaceMethod : narrowed.methods()) {
for (VariableDeclaration param : interfaceMethod.params()) {
generation.processGenerationResult(reader.readUpdater(interfaceMethod, param, param.type().declarable(), false));
}
VariableDeclaration param = interfaceMethod.varParam();
if (param != null) {
generation.processGenerationResult(reader.readUpdater(interfaceMethod, param, param.type().declarable(), true));
}
}
return generation.createGenerationResult(updatersMap);
}
Aggregations