use of com.querydsl.codegen.utils.model.Constructor 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.Constructor in project querydsl by querydsl.
the class ProjectionSerializerTest method constructors.
@Test
public void constructors() throws IOException {
Type typeModel = new SimpleType(TypeCategory.ENTITY, "com.querydsl.DomainClass", "com.querydsl", "DomainClass", false, false);
EntityType type = new EntityType(typeModel);
// constructor
Parameter firstName = new Parameter("firstName", Types.STRING);
Parameter lastName = new Parameter("lastName", Types.STRING);
Parameter age = new Parameter("age", Types.INTEGER);
type.addConstructor(new Constructor(Arrays.asList(firstName, lastName, age)));
Writer writer = new StringWriter();
ProjectionSerializer serializer = new DefaultProjectionSerializer(new JavaTypeMappings());
serializer.serialize(type, SimpleSerializerConfig.DEFAULT, new JavaWriter(writer));
assertTrue(writer.toString().contains("Expression<String> firstName"));
assertTrue(writer.toString().contains("Expression<String> lastName"));
assertTrue(writer.toString().contains("Expression<Integer> age"));
}
Aggregations