Search in sources :

Example 6 with TypeCategory

use of com.querydsl.codegen.utils.model.TypeCategory 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");
}
Also used : Type(com.querydsl.codegen.utils.model.Type) ClassType(com.querydsl.codegen.utils.model.ClassType) TypeCategory(com.querydsl.codegen.utils.model.TypeCategory) ClassType(com.querydsl.codegen.utils.model.ClassType) Annotation(java.lang.annotation.Annotation)

Aggregations

Type (com.querydsl.codegen.utils.model.Type)6 TypeCategory (com.querydsl.codegen.utils.model.TypeCategory)6 EntityType (com.querydsl.codegen.EntityType)4 ClassType (com.querydsl.codegen.utils.model.ClassType)3 SimpleType (com.querydsl.codegen.utils.model.SimpleType)3 Property (com.querydsl.codegen.Property)2 PropertyType (com.querydsl.core.annotations.PropertyType)2 QueryType (com.querydsl.core.annotations.QueryType)2 Annotation (java.lang.annotation.Annotation)2 QueryInit (com.querydsl.core.annotations.QueryInit)1 ColumnImpl (com.querydsl.sql.ColumnImpl)1 ColumnMetadata (com.querydsl.sql.ColumnMetadata)1 NotNullImpl (com.querydsl.sql.codegen.support.NotNullImpl)1 SizeImpl (com.querydsl.sql.codegen.support.SizeImpl)1 TypeElement (javax.lang.model.element.TypeElement)1 ArrayType (javax.lang.model.type.ArrayType)1 DeclaredType (javax.lang.model.type.DeclaredType)1 ErrorType (javax.lang.model.type.ErrorType)1 ExecutableType (javax.lang.model.type.ExecutableType)1 NoType (javax.lang.model.type.NoType)1