use of com.querydsl.codegen.utils.model.Type in project querydsl by querydsl.
the class GenericExporter method addConstructors.
private void addConstructors(Class<?> cl, EntityType type) {
for (Constructor<?> constructor : cl.getConstructors()) {
if (constructor.isAnnotationPresent(QueryProjection.class)) {
List<Parameter> parameters = new ArrayList<>();
for (int i = 0; i < constructor.getParameterTypes().length; i++) {
Type parameterType = typeFactory.get(constructor.getParameterTypes()[i], constructor.getGenericParameterTypes()[i]);
for (Annotation annotation : constructor.getParameterAnnotations()[i]) {
if (annotation.annotationType().equals(QueryType.class)) {
QueryType queryType = (QueryType) annotation;
parameterType = parameterType.as(TypeCategory.valueOf(queryType.value().name()));
}
}
parameters.add(new Parameter("param" + i, parameterType));
}
type.addConstructor(new com.querydsl.codegen.utils.model.Constructor(parameters));
}
}
}
use of com.querydsl.codegen.utils.model.Type in project querydsl by querydsl.
the class Inheritance2Test method base_base.
@Test
public void base_base() throws SecurityException, NoSuchFieldException {
TypeFactory typeFactory = new TypeFactory();
Field field = Base.class.getDeclaredField("base");
Type type = typeFactory.get(field.getType(), field.getGenericType());
assertEquals(0, type.getParameters().size());
}
use of com.querydsl.codegen.utils.model.Type in project querydsl by querydsl.
the class Inheritance2Test method base_base2.
@Test
public void base_base2() throws SecurityException, NoSuchFieldException {
TypeFactory typeFactory = new TypeFactory();
Field field = Base.class.getDeclaredField("base2");
Type type = typeFactory.get(field.getType(), field.getGenericType());
assertEquals(2, type.getParameters().size());
assertNull(((TypeExtends) type.getParameters().get(0)).getVarName());
assertNull(((TypeExtends) type.getParameters().get(1)).getVarName());
}
use of com.querydsl.codegen.utils.model.Type in project querydsl by querydsl.
the class Generic2Test method resolve2.
@Test
public void resolve2() {
TypeFactory factory = new TypeFactory(Collections.<Class<? extends Annotation>>emptyList());
Type type = factory.getEntityType(AbstractCollectionAttribute.class);
assertEquals("com.querydsl.codegen.Generic2Test.AbstractCollectionAttribute<? extends java.util.Collection<?>>", type.getGenericName(false));
assertEquals("com.querydsl.codegen.Generic2Test.AbstractCollectionAttribute<? extends java.util.Collection<?>>", type.getGenericName(true));
}
use of com.querydsl.codegen.utils.model.Type in project querydsl by querydsl.
the class Generic2Test method resolve.
@Test
public void resolve() {
TypeFactory factory = new TypeFactory(Collections.<Class<? extends Annotation>>emptyList());
Type type = factory.get(AbstractCollectionAttribute.class);
assertEquals("com.querydsl.codegen.Generic2Test.AbstractCollectionAttribute", type.getGenericName(false));
assertEquals("com.querydsl.codegen.Generic2Test.AbstractCollectionAttribute", type.getGenericName(true));
}
Aggregations