use of com.querydsl.codegen.utils.model.ClassType in project querydsl by querydsl.
the class EntityTypeTest method uncapSimpleName_escaped.
@Test
public void uncapSimpleName_escaped() {
ClassType typeModel = new ClassType(TypeCategory.ENTITY, Object.class);
EntityType entityModel = new EntityType(typeModel);
assertEquals("object", entityModel.getModifiedSimpleName());
entityModel.addProperty(new Property(entityModel, "object", typeModel));
assertEquals("object1", entityModel.getModifiedSimpleName());
}
use of com.querydsl.codegen.utils.model.ClassType in project querydsl by querydsl.
the class DefaultEmbeddableSerializer method introClassHeader.
@Override
@SuppressWarnings(UNCHECKED)
protected void introClassHeader(CodeWriter writer, EntityType model) throws IOException {
Type queryType = typeMappings.getPathType(model, model, true);
TypeCategory category = model.getOriginalCategory();
Class<? extends Path> pathType;
if (model.getProperties().isEmpty()) {
switch(category) {
case COMPARABLE:
pathType = ComparablePath.class;
break;
case ENUM:
pathType = EnumPath.class;
break;
case DATE:
pathType = DatePath.class;
break;
case DATETIME:
pathType = DateTimePath.class;
break;
case TIME:
pathType = TimePath.class;
break;
case NUMERIC:
pathType = NumberPath.class;
break;
case STRING:
pathType = StringPath.class;
break;
case BOOLEAN:
pathType = BooleanPath.class;
break;
default:
pathType = BeanPath.class;
}
} else {
pathType = BeanPath.class;
}
for (Annotation annotation : model.getAnnotations()) {
writer.annotation(annotation);
}
writer.line("@", generatedAnnotationClass.getSimpleName(), "(\"", getClass().getName(), "\")");
if (category == TypeCategory.BOOLEAN || category == TypeCategory.STRING) {
writer.beginClass(queryType, new ClassType(pathType));
} else {
writer.beginClass(queryType, new ClassType(category, pathType, model));
}
// TODO : generate proper serialVersionUID here
writer.privateStaticFinal(Types.LONG_P, "serialVersionUID", model.hashCode() + "L");
}
use of com.querydsl.codegen.utils.model.ClassType in project querydsl by querydsl.
the class ScalaWriterTest method Arrays.
@Test
public void Arrays() throws IOException {
// def main(args: Array[String]) {
writer.beginClass(new SimpleType("Main"));
writer.field(Types.STRING.asArrayType(), "stringArray");
writer.beginPublicMethod(Types.VOID, "main", new Parameter("args", Types.STRING.asArrayType()));
writer.line("//");
writer.end();
writer.beginPublicMethod(Types.VOID, "main2", new Parameter("args", new ClassType(TypeCategory.ARRAY, String[].class)));
writer.line("//");
writer.end();
writer.end();
System.out.println(w);
assertTrue(w.toString().contains("var stringArray: Array[String]"));
assertTrue(w.toString().contains("def main(args: Array[String])"));
assertTrue(w.toString().contains("def main2(args: Array[String])"));
}
use of com.querydsl.codegen.utils.model.ClassType in project querydsl by querydsl.
the class JavaWriterTest method Primitive_Arrays.
@Test
public void Primitive_Arrays() {
ClassType byteArray = new ClassType(byte[].class);
assertEquals("byte[]", writer.getRawName(byteArray));
}
use of com.querydsl.codegen.utils.model.ClassType in project querydsl by querydsl.
the class InnerClassesTest method DirectParameter.
@Test
public void DirectParameter() throws IOException {
Type entityType = new ClassType(Entity.class);
Type type = new SimpleType("com.querydsl.codegen.utils.gen.QEntity", "com.querydsl.codegen.utils.gen", "QEntity", entityType);
StringWriter str = new StringWriter();
JavaWriter writer = new JavaWriter(str);
writer.beginClass(type);
writer.end();
System.err.println(str.toString());
}
Aggregations