Search in sources :

Example 1 with PropertyType

use of com.querydsl.core.annotations.PropertyType in project querydsl by querydsl.

the class TypeElementHandler method toProperty.

private Property toProperty(EntityType entityType, String name, TypeMirror type, Annotations annotations) {
    // type
    Type propertyType = typeFactory.getType(type, true);
    if (annotations.isAnnotationPresent(QueryType.class)) {
        PropertyType propertyTypeAnn = annotations.getAnnotation(QueryType.class).value();
        if (propertyTypeAnn != PropertyType.NONE) {
            TypeCategory typeCategory = TypeCategory.valueOf(annotations.getAnnotation(QueryType.class).value().name());
            if (typeCategory == null) {
                return null;
            }
            propertyType = propertyType.as(typeCategory);
        } else {
            return null;
        }
    }
    // inits
    List<String> inits = Collections.emptyList();
    if (annotations.isAnnotationPresent(QueryInit.class)) {
        inits = ImmutableList.copyOf(annotations.getAnnotation(QueryInit.class).value());
    }
    return new Property(entityType, name, propertyType, inits);
}
Also used : QueryType(com.querydsl.core.annotations.QueryType) Type(com.mysema.codegen.model.Type) PropertyType(com.querydsl.core.annotations.PropertyType) EntityType(com.querydsl.codegen.EntityType) QueryInit(com.querydsl.core.annotations.QueryInit) TypeCategory(com.mysema.codegen.model.TypeCategory) PropertyType(com.querydsl.core.annotations.PropertyType) QueryType(com.querydsl.core.annotations.QueryType) Property(com.querydsl.codegen.Property)

Aggregations

Type (com.mysema.codegen.model.Type)1 TypeCategory (com.mysema.codegen.model.TypeCategory)1 EntityType (com.querydsl.codegen.EntityType)1 Property (com.querydsl.codegen.Property)1 PropertyType (com.querydsl.core.annotations.PropertyType)1 QueryInit (com.querydsl.core.annotations.QueryInit)1 QueryType (com.querydsl.core.annotations.QueryType)1