use of com.querydsl.codegen.utils.model.Parameter in project querydsl by querydsl.
the class TypeElementHandler method handleConstructors.
private void handleConstructors(EntityType entityType, List<? extends Element> elements) {
for (ExecutableElement constructor : ElementFilter.constructorsIn(elements)) {
if (configuration.isValidConstructor(constructor)) {
List<Parameter> parameters = transformParams(constructor.getParameters());
entityType.addConstructor(new Constructor(parameters));
}
}
}
use of com.querydsl.codegen.utils.model.Parameter in project querydsl by querydsl.
the class AbstractQuerydslProcessor method processDelegateMethods.
private Set<TypeElement> processDelegateMethods() {
Set<? extends Element> delegateMethods = getElements(QueryDelegate.class);
Set<TypeElement> typeElements = new HashSet<TypeElement>();
for (Element delegateMethod : delegateMethods) {
ExecutableElement method = (ExecutableElement) delegateMethod;
Element element = delegateMethod.getEnclosingElement();
String name = method.getSimpleName().toString();
Type delegateType = typeFactory.getType(element.asType(), true);
Type returnType = typeFactory.getType(method.getReturnType(), true);
List<Parameter> parameters = elementHandler.transformParams(method.getParameters());
// remove first element
parameters = parameters.subList(1, parameters.size());
EntityType entityType = null;
for (AnnotationMirror annotation : delegateMethod.getAnnotationMirrors()) {
if (TypeUtils.isAnnotationMirrorOfType(annotation, QueryDelegate.class)) {
TypeMirror type = TypeUtils.getAnnotationValueAsTypeMirror(annotation, "value");
if (type != null) {
entityType = typeFactory.getEntityType(type, true);
}
}
}
if (entityType != null) {
registerTypeElement(entityType.getFullName(), (TypeElement) element);
entityType.addDelegate(new Delegate(entityType, delegateType, name, parameters, returnType));
TypeElement typeElement = processingEnv.getElementUtils().getTypeElement(entityType.getFullName());
boolean isAnnotated = false;
for (Class<? extends Annotation> ann : conf.getEntityAnnotations()) {
if (typeElement.getAnnotation(ann) != null) {
isAnnotated = true;
}
}
if (isAnnotated) {
// handle also properties of entity type
typeElements.add(processingEnv.getElementUtils().getTypeElement(entityType.getFullName()));
} else {
// skip handling properties
context.extensionTypes.put(entityType.getFullName(), entityType);
context.allTypes.put(entityType.getFullName(), entityType);
}
}
}
return typeElements;
}
use of com.querydsl.codegen.utils.model.Parameter in project querydsl by querydsl.
the class MetaDataSerializer method constructorsForVariables.
@Override
protected void constructorsForVariables(CodeWriter writer, EntityType model) throws IOException {
super.constructorsForVariables(writer, model);
String localName = writer.getRawName(model);
String genericName = writer.getGenericName(true, model);
if (!localName.equals(genericName)) {
writer.suppressWarnings("all");
}
writer.beginConstructor(new Parameter("variable", Types.STRING), new Parameter("schema", Types.STRING), new Parameter("table", Types.STRING));
writer.line(SUPER, "(", writer.getClassConstant(localName) + COMMA + "forVariable(variable), schema, table);");
constructorContent(writer, model);
writer.end();
writer.beginConstructor(new Parameter("variable", Types.STRING), new Parameter("schema", Types.STRING));
writer.line(SUPER, "(", writer.getClassConstant(localName), COMMA, "forVariable(variable), schema, \"", model.getData().get("table").toString(), "\");");
constructorContent(writer, model);
writer.end();
}
use of com.querydsl.codegen.utils.model.Parameter in project querydsl by querydsl.
the class ScalaWriterTest method BeanAccessors.
@Test
public void BeanAccessors() throws IOException {
writer.beginClass(new SimpleType("Person"));
writer.beginPublicMethod(Types.STRING, "getName");
writer.line("\"Daniel Spiewak\"");
writer.end();
writer.beginPublicMethod(Types.VOID, "setName", new Parameter("name", Types.STRING));
writer.line("//");
writer.end();
writer.end();
System.out.println(w);
}
use of com.querydsl.codegen.utils.model.Parameter in project querydsl by querydsl.
the class ScalaWriterTest method Constructors.
@Test
public void Constructors() throws IOException {
writer.beginClass(testType);
writer.beginConstructor(Arrays.asList(new Parameter("a", Types.STRING), new Parameter("b", Types.STRING)), transformer);
writer.end();
writer.beginConstructor(new Parameter("a", Types.STRING));
writer.end();
writer.end();
System.out.println(w);
}
Aggregations