use TypeElement instead of String
Signed-off-by: Gavin King <gavin@hibernate.org>
This commit is contained in:
parent
cdb92a3049
commit
dc0442ad01
|
@ -359,25 +359,25 @@ public final class TypeUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void updateEmbeddableAccessTypeForMember(Context context, AccessType defaultAccessType, Element member) {
|
private static void updateEmbeddableAccessTypeForMember(Context context, AccessType defaultAccessType, Element member) {
|
||||||
final String embeddedClassName = member.asType().accept( new EmbeddedAttributeVisitor( context ), member );
|
final @Nullable TypeElement embedded = member.asType().accept( new EmbeddedAttributeVisitor( context ), member );
|
||||||
if ( embeddedClassName != null ) {
|
if ( embedded != null ) {
|
||||||
updateEmbeddableAccessType( context, defaultAccessType, embeddedClassName );
|
updateEmbeddableAccessType( context, defaultAccessType, embedded );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void updateEmbeddableAccessType(Context context, AccessType defaultAccessType, String embeddedClassName) {
|
private static void updateEmbeddableAccessType(Context context, AccessType defaultAccessType, TypeElement embedded) {
|
||||||
final AccessTypeInformation accessTypeInfo = context.getAccessTypeInfo( embeddedClassName );
|
final String embeddedClassName = embedded.getQualifiedName().toString();
|
||||||
|
final AccessTypeInformation accessTypeInfo = context.getAccessTypeInfo(embeddedClassName);
|
||||||
if ( accessTypeInfo == null ) {
|
if ( accessTypeInfo == null ) {
|
||||||
final AccessTypeInformation newAccessTypeInfo =
|
final AccessTypeInformation newAccessTypeInfo =
|
||||||
new AccessTypeInformation( embeddedClassName, null, defaultAccessType );
|
new AccessTypeInformation( embeddedClassName, null, defaultAccessType );
|
||||||
context.addAccessTypeInformation( embeddedClassName, newAccessTypeInfo );
|
context.addAccessTypeInformation( embeddedClassName, newAccessTypeInfo );
|
||||||
final TypeElement typeElement = context.getElementUtils().getTypeElement( embeddedClassName );
|
updateEmbeddableAccessType( embedded, context, defaultAccessType );
|
||||||
updateEmbeddableAccessType( typeElement, context, defaultAccessType );
|
final TypeMirror superclass = embedded.getSuperclass();
|
||||||
final TypeMirror superclass = typeElement.getSuperclass();
|
|
||||||
if ( superclass.getKind() == TypeKind.DECLARED ) {
|
if ( superclass.getKind() == TypeKind.DECLARED ) {
|
||||||
final DeclaredType declaredType = (DeclaredType) superclass;
|
final DeclaredType declaredType = (DeclaredType) superclass;
|
||||||
final TypeElement element = (TypeElement) declaredType.asElement();
|
final TypeElement element = (TypeElement) declaredType.asElement();
|
||||||
updateEmbeddableAccessType( context, defaultAccessType, element.getQualifiedName().toString() );
|
updateEmbeddableAccessType( context, defaultAccessType, element );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -654,7 +654,7 @@ public final class TypeUtils {
|
||||||
|| !entityMetaComplete && containsAnnotation( superClassElement, ENTITY, MAPPED_SUPERCLASS );
|
|| !entityMetaComplete && containsAnnotation( superClassElement, ENTITY, MAPPED_SUPERCLASS );
|
||||||
}
|
}
|
||||||
|
|
||||||
static class EmbeddedAttributeVisitor extends SimpleTypeVisitor8<@Nullable String, Element> {
|
static class EmbeddedAttributeVisitor extends SimpleTypeVisitor8<@Nullable TypeElement, Element> {
|
||||||
private final Context context;
|
private final Context context;
|
||||||
|
|
||||||
EmbeddedAttributeVisitor(Context context) {
|
EmbeddedAttributeVisitor(Context context) {
|
||||||
|
@ -662,16 +662,14 @@ public final class TypeUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @Nullable String visitDeclared(DeclaredType declaredType, Element element) {
|
public @Nullable TypeElement visitDeclared(DeclaredType declaredType, Element element) {
|
||||||
final TypeElement returnedElement = (TypeElement)
|
final TypeElement returnedElement = (TypeElement)
|
||||||
context.getTypeUtils().asElement( declaredType );
|
context.getTypeUtils().asElement( declaredType );
|
||||||
return containsAnnotation( returnedElement, EMBEDDABLE )
|
return containsAnnotation( returnedElement, EMBEDDABLE ) ? returnedElement : null;
|
||||||
? returnedElement.getQualifiedName().toString()
|
|
||||||
: null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @Nullable String visitExecutable(ExecutableType executable, Element element) {
|
public @Nullable TypeElement visitExecutable(ExecutableType executable, Element element) {
|
||||||
if ( element.getKind().equals( ElementKind.METHOD ) ) {
|
if ( element.getKind().equals( ElementKind.METHOD ) ) {
|
||||||
final String string = element.getSimpleName().toString();
|
final String string = element.getSimpleName().toString();
|
||||||
return isProperty( string, toTypeString( executable.getReturnType() ) )
|
return isProperty( string, toTypeString( executable.getReturnType() ) )
|
||||||
|
|
Loading…
Reference in New Issue