use of com.mysema.codegen.model.ClassType in project querydsl by querydsl.
the class CustomTypeTest method customType.
@Test
public void customType() throws IOException {
SimpleType type = new SimpleType(TypeCategory.ENTITY, "Entity", "", "Entity", false, false);
EntityType entityType = new EntityType(type);
entityType.addProperty(new Property(entityType, "property", new ClassType(Double[].class)));
typeMappings.register(new ClassType(Double[].class), new ClassType(Point.class));
typeMappings.register(entityType, queryTypeFactory.create(entityType));
assertTrue(typeMappings.isRegistered(entityType.getProperties().iterator().next().getType()));
serializer.serialize(entityType, SimpleSerializerConfig.DEFAULT, new JavaWriter(writer));
assertTrue(writer.toString().contains("public final com.querydsl.codegen.Point property = " + "new com.querydsl.codegen.Point(forProperty(\"property\"));"));
}
use of com.mysema.codegen.model.ClassType in project querydsl by querydsl.
the class ScalaTypeDump method test.
@Test
@Ignore
public void test() throws IOException {
List<Class<?>> classes = new ArrayList<Class<?>>();
classes.add(SimpleExpression.class);
classes.add(ComparableExpression.class);
classes.add(BooleanExpression.class);
classes.add(StringExpression.class);
classes.add(TemporalExpression.class);
classes.add(TimeExpression.class);
classes.add(DateTimeExpression.class);
classes.add(DateExpression.class);
classes.add(EnumExpression.class);
classes.add(NumberExpression.class);
StringWriter w = new StringWriter();
ScalaWriter writer = new ScalaWriter(w);
writer.packageDecl("com.querydsl.scala");
writer.imports(Expression.class.getPackage());
for (Class<?> cl : classes) {
Type type = new ClassType(cl);
Type superClass = new ClassType(cl.getSuperclass());
writer.beginClass(type, superClass);
for (Method m : cl.getDeclaredMethods()) {
List<Parameter> params = new ArrayList<Parameter>();
for (Class<?> paramType : m.getParameterTypes()) {
params.add(new Parameter("arg" + params.size(), new ClassType(paramType)));
}
Type returnType = new ClassType(m.getReturnType());
writer.beginPublicMethod(returnType, ":" + m.getName(), params.toArray(new Parameter[params.size()]));
writer.end();
}
writer.end();
}
System.out.println(w);
}
use of com.mysema.codegen.model.ClassType in project querydsl by querydsl.
the class TypeMappingsTest method getPathType_of_innerClass.
@Test
public void getPathType_of_innerClass() {
TypeMappings typeMappings = new JavaTypeMappings();
EntityType model = new EntityType(new ClassType(TypeMappingsTest.class));
EntityType type = new EntityType(new ClassType(Entity.class));
typeMappings.register(type, new QueryTypeFactoryImpl("Q", "", "").create(type));
Type pathType = typeMappings.getPathType(type, model, false);
assertEquals("QTypeMappingsTest_Entity", pathType.getSimpleName());
}
use of com.mysema.codegen.model.ClassType in project querydsl by querydsl.
the class EntityTypeTest method uncapSimpleName_escaped2.
@Test
public void uncapSimpleName_escaped2() {
ClassType typeModel = new ClassType(TypeCategory.ENTITY, Object.class);
EntityType entityModel = new EntityType(typeModel);
assertEquals("object", entityModel.getModifiedSimpleName());
entityModel.addProperty(new Property(entityModel, "OBJECT", "object", typeModel, Collections.<String>emptyList(), false));
assertEquals("object1", entityModel.getModifiedSimpleName());
}
use of com.mysema.codegen.model.ClassType in project querydsl by querydsl.
the class EntityTypeTest method uncapSimpleName_escaped3.
@Test
public void uncapSimpleName_escaped3() {
ClassType typeModel = new ClassType(TypeCategory.ENTITY, Void.class);
EntityType entityModel = new EntityType(typeModel);
assertEquals("void$", entityModel.getModifiedSimpleName());
}
Aggregations