@Nullable public EntityType getEntityType(TypeMirror typeMirror, boolean deep) { List<String> key = keyBuilder.visit(typeMirror, true); // get from cache if (entityTypeCache.containsKey(key)) { EntityType entityType = entityTypeCache.get(key); if (deep && entityType.getSuperTypes().isEmpty()) { for (Type superType : getSupertypes(typeMirror, deep)) { entityType.addSupertype(new Supertype(superType)); } } return entityType; // create } else { return createEntityType(typeMirror, key, deep); } }
type.addSupertype(new Supertype(typeFactory.get(cl.getSuperclass(), cl.getGenericSuperclass()))); type.addSupertype(new Supertype(typeFactory.get(iface)));
@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; } }
private EntityType createEntityType(Class<?> cl, Map<Class<?>, EntityType> types) { if (allTypes.containsKey(cl)) { return allTypes.get(cl); } else { EntityType type = typeFactory.getEntityType(cl); registerConfig(type); typeMappings.register(type, queryTypeFactory.create(type)); if (!cl.getSuperclass().equals(Object.class)) { type.addSupertype(new Supertype(typeFactory.get(cl.getSuperclass(), cl.getGenericSuperclass()))); } types.put(cl, type); allTypes.put(cl, type); return type; } }
protected EntityType createEntityType(Type type, Map<Class<?>, EntityType> types) { Class<?> key = type.getJavaClass(); if (allTypes.containsKey(key)) { return allTypes.get(key); } else { EntityType entityType = new EntityType(type, variableNameFunction); registerConfig(entityType); typeMappings.register(entityType, queryTypeFactory.create(entityType)); Class<?> superClass = key.getSuperclass(); if (entityType.getSuperType() == null && superClass != null && !superClass.equals(Object.class)) { entityType.addSupertype(new Supertype(typeFactory.get(superClass, key.getGenericSuperclass()))); } types.put(key, entityType); allTypes.put(key, entityType); return entityType; } }