use of com.querydsl.codegen.utils.model.Type in project querydsl by querydsl.
the class ExtendedTypeFactory method createEntityType.
@Nullable
private EntityType createEntityType(TypeMirror typeMirror, List<String> key, boolean deep) {
entityTypeCache.put(key, null);
Type value = visitor.visit(typeMirror, deep);
if (value != null) {
EntityType entityType = null;
if (value instanceof EntityType) {
entityType = (EntityType) value;
} else {
entityType = new EntityType(value, variableNameFunction);
typeMappings.register(entityType, queryTypeFactory.create(entityType));
}
entityTypeCache.put(key, entityType);
if (deep) {
for (Type superType : getSupertypes(typeMirror, deep)) {
entityType.addSupertype(new Supertype(superType));
}
}
return entityType;
} else {
return null;
}
}
use of com.querydsl.codegen.utils.model.Type in project querydsl by querydsl.
the class ExtendedTypeFactory method createType.
@Nullable
private Type createType(TypeMirror typeMirror, List<String> key, boolean deep) {
typeCache.put(key, null);
Type type = visitor.visit(typeMirror, deep);
if (type != null && (type.getCategory() == TypeCategory.ENTITY || type.getCategory() == TypeCategory.CUSTOM)) {
EntityType entityType = getEntityType(typeMirror, deep);
typeCache.put(key, entityType);
return entityType;
} else {
typeCache.put(key, type);
return type;
}
}
use of com.querydsl.codegen.utils.model.Type in project querydsl by querydsl.
the class ExtendedTypeFactory method getSupertypes.
private Set<Type> getSupertypes(TypeMirror typeMirror, boolean deep) {
boolean doubleIndex = doubleIndexEntities;
doubleIndexEntities = false;
Set<Type> superTypes = Collections.emptySet();
typeMirror = normalize(typeMirror);
if (typeMirror.getKind() == TypeKind.DECLARED) {
DeclaredType declaredType = (DeclaredType) typeMirror;
TypeElement e = (TypeElement) declaredType.asElement();
// class
if (e.getKind() == ElementKind.CLASS) {
if (e.getSuperclass().getKind() != TypeKind.NONE) {
TypeMirror supertype = normalize(e.getSuperclass());
if (supertype instanceof DeclaredType && ((DeclaredType) supertype).asElement().getAnnotation(QueryExclude.class) != null) {
return Collections.emptySet();
} else {
Type superClass = getType(supertype, deep);
if (superClass == null) {
System.err.println("Got no type for " + supertype);
} else if (!superClass.getFullName().startsWith("java")) {
superTypes = Collections.singleton(getType(supertype, deep));
}
}
}
// interface
} else {
superTypes = new LinkedHashSet<Type>(e.getInterfaces().size());
for (TypeMirror mirror : e.getInterfaces()) {
Type iface = getType(mirror, deep);
if (!iface.getFullName().startsWith("java")) {
superTypes.add(iface);
}
}
}
} else {
return Collections.emptySet();
}
doubleIndexEntities = doubleIndex;
return superTypes;
}
use of com.querydsl.codegen.utils.model.Type in project querydsl by querydsl.
the class TypeElementHandler method handleProjectionType.
public EntityType handleProjectionType(TypeElement e) {
Type c = typeFactory.getType(e.asType(), true);
EntityType entityType = new EntityType(c.as(TypeCategory.ENTITY), configuration.getVariableNameFunction());
typeMappings.register(entityType, queryTypeFactory.create(entityType));
List<? extends Element> elements = e.getEnclosedElements();
handleConstructors(entityType, elements);
return entityType;
}
use of com.querydsl.codegen.utils.model.Type in project querydsl by querydsl.
the class TypeElementHandler method getType.
private Type getType(VariableElement element) {
Type rv = typeFactory.getType(element.asType(), true);
if (element.getAnnotation(QueryType.class) != null) {
QueryType qt = element.getAnnotation(QueryType.class);
if (qt.value() != PropertyType.NONE) {
TypeCategory typeCategory = TypeCategory.valueOf(qt.value().name());
rv = rv.as(typeCategory);
}
}
return rv;
}
Aggregations