Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.hibernate.models.spi.ArrayTypeDetails;
import org.hibernate.models.spi.ClassDetails;
import org.hibernate.models.spi.TypeDetails;
import org.hibernate.models.spi.TypeVariableDetails;

/**
* @author Steve Ebersole
Expand Down Expand Up @@ -84,9 +85,9 @@ public boolean isImplementor(Class<?> checkType) {
}

@Override
public TypeDetails resolveTypeVariable(String identifier) {
public TypeDetails resolveTypeVariable(TypeVariableDetails typeVariable) {
if ( constituentType.getTypeKind() == Kind.PARAMETERIZED_TYPE ) {
return constituentType.asParameterizedType().resolveTypeVariable( identifier );
return constituentType.asParameterizedType().resolveTypeVariable( typeVariable );
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.hibernate.models.spi.ClassDetails;
import org.hibernate.models.spi.ClassTypeDetails;
import org.hibernate.models.spi.TypeDetails;
import org.hibernate.models.spi.TypeVariableDetails;

/**
* @author Steve Ebersole
Expand Down Expand Up @@ -42,8 +43,8 @@ public Kind getTypeKind() {
}

@Override
public TypeDetails resolveTypeVariable(String identifier) {
return getClassDetails().resolveTypeVariable( identifier );
public TypeDetails resolveTypeVariable(TypeVariableDetails typeVariable) {
return getClassDetails().resolveTypeVariable( typeVariable );
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,15 @@ public TypeDetails caseWildcardType(WildcardTypeDetails wildcardType) {
@Override
public TypeDetails caseTypeVariable(TypeVariableDetails typeVariable) {
if ( typeVariable.isImplementor( Collection.class ) ) {
return memberTypeDetails.resolveTypeVariable( typeVariable.getIdentifier() );
return memberTypeDetails.resolveTypeVariable( typeVariable );
}
return null;
}

@Override
public TypeDetails caseTypeVariableReference(TypeVariableReferenceDetails typeVariableReference) {
if ( typeVariableReference.isImplementor( Collection.class ) ) {
return memberTypeDetails.resolveTypeVariable( typeVariableReference.getIdentifier() );
return memberTypeDetails.resolveTypeVariable( typeVariableReference.getTarget() );
}
return null;
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/hibernate/models/internal/MapKeySwitch.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,15 @@ public TypeDetails caseWildcardType(WildcardTypeDetails wildcardType) {
@Override
public TypeDetails caseTypeVariable(TypeVariableDetails typeVariable) {
if ( typeVariable.isImplementor( Map.class ) ) {
return memberTypeDetails.resolveTypeVariable( typeVariable.getIdentifier() );
return memberTypeDetails.resolveTypeVariable( typeVariable );
}
return null;
}

@Override
public TypeDetails caseTypeVariableReference(TypeVariableReferenceDetails typeVariableReference) {
if ( typeVariableReference.isImplementor( Map.class ) ) {
return memberTypeDetails.resolveTypeVariable( typeVariableReference.getIdentifier() );
return memberTypeDetails.resolveTypeVariable( typeVariableReference.getTarget() );
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,15 @@ public TypeDetails caseWildcardType(WildcardTypeDetails wildcardType) {
@Override
public TypeDetails caseTypeVariable(TypeVariableDetails typeVariable) {
if ( typeVariable.isImplementor( Map.class ) ) {
return memberTypeDetails.resolveTypeVariable( typeVariable.getIdentifier() );
return memberTypeDetails.resolveTypeVariable( typeVariable );
}
return null;
}

@Override
public TypeDetails caseTypeVariableReference(TypeVariableReferenceDetails typeVariableReference) {
if ( typeVariableReference.isImplementor( Map.class ) ) {
return memberTypeDetails.resolveTypeVariable( typeVariableReference.getIdentifier() );
return memberTypeDetails.resolveTypeVariable( typeVariableReference.getTarget() );
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
import org.hibernate.models.spi.TypeVariableDetails;
import org.hibernate.models.spi.TypeVariableScope;

import static org.hibernate.models.spi.TypeDetailsHelper.resolveTypeVariableFromParameterizedType;

/**
* @author Steve Ebersole
*/
Expand Down Expand Up @@ -45,16 +47,7 @@ public TypeVariableScope getOwner() {
}

@Override
public TypeDetails resolveTypeVariable(String identifier) {
final List<TypeVariableDetails> typeParameters = genericClassDetails.getTypeParameters();
assert typeParameters.size() == arguments.size();

for ( int i = 0; i < typeParameters.size(); i++ ) {
if ( typeParameters.get( i ).getIdentifier().equals( identifier ) ) {
return arguments.get( i );
}
}

return null;
public TypeDetails resolveTypeVariable(TypeVariableDetails typeVariable) {
return resolveTypeVariableFromParameterizedType( this, typeVariable );
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.hibernate.models.spi.ClassDetails;
import org.hibernate.models.spi.PrimitiveTypeDetails;
import org.hibernate.models.spi.TypeDetails;
import org.hibernate.models.spi.TypeVariableDetails;

/**
* @author Steve Ebersole
Expand All @@ -31,7 +32,7 @@ public PrimitiveTypeDetails asPrimitiveType() {
}

@Override
public TypeDetails resolveTypeVariable(String identifier) {
public TypeDetails resolveTypeVariable(TypeVariableDetails typeVariable) {
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import java.util.List;

import org.hibernate.models.spi.ClassDetails;
import org.hibernate.models.spi.TypeDetails;
import org.hibernate.models.spi.TypeVariableDetails;

Expand All @@ -17,12 +18,14 @@
*/
public class TypeVariableDetailsImpl implements TypeVariableDetails {
private final String identifier;
private final ClassDetails declaringType;
private final List<TypeDetails> bounds;

private final String name;

public TypeVariableDetailsImpl(String identifier, List<TypeDetails> bounds) {
public TypeVariableDetailsImpl(String identifier, ClassDetails declaringType, List<TypeDetails> bounds) {
this.identifier = identifier;
this.declaringType = declaringType;
this.bounds = bounds;

this.name = calculateName( bounds );
Expand All @@ -39,6 +42,10 @@ private String calculateName(List<TypeDetails> bounds) {
return identifier;
}

@Override public ClassDetails getDeclaringType() {
return declaringType;
}

@Override public List<TypeDetails> getBounds() {
return bounds;
}
Expand All @@ -57,8 +64,8 @@ public boolean isImplementor(Class<?> checkType) {
}

@Override
public TypeDetails resolveTypeVariable(String identifier) {
return this.identifier.equals( identifier ) ? this : null;
public TypeDetails resolveTypeVariable(TypeVariableDetails typeVariable) {
return identifier.equals( typeVariable.getIdentifier() ) ? this : null;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public boolean isImplementor(Class<?> checkType) {
}

@Override
public TypeDetails resolveTypeVariable(String identifier) {
return this.identifier.equals( identifier ) ? target : null;
public TypeDetails resolveTypeVariable(TypeVariableDetails typeVariable) {
return this.identifier.equals( typeVariable.getIdentifier() ) ? target : null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import org.hibernate.models.spi.ClassDetails;
import org.hibernate.models.spi.TypeDetails;
import org.hibernate.models.spi.TypeVariableDetails;
import org.hibernate.models.spi.VoidTypeDetails;

/**
Expand Down Expand Up @@ -41,7 +42,7 @@ public VoidTypeDetails asVoidType() {
}

@Override
public TypeDetails resolveTypeVariable(String identifier) {
public TypeDetails resolveTypeVariable(TypeVariableDetails typeVariable) {
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import org.hibernate.models.spi.ClassTypeDetails;
import org.hibernate.models.spi.TypeDetails;
import org.hibernate.models.spi.TypeVariableDetails;
import org.hibernate.models.spi.WildcardTypeDetails;

/**
Expand Down Expand Up @@ -74,7 +75,7 @@ public boolean isImplementor(Class<?> checkType) {
}

@Override
public TypeDetails resolveTypeVariable(String identifier) {
public TypeDetails resolveTypeVariable(TypeVariableDetails typeVariable) {
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
import org.jboss.jandex.MethodInfo;
import org.jboss.jandex.Type;

import static org.hibernate.models.internal.jandex.JandexTypeSwitchStandard.TYPE_SWITCH_STANDARD;
import static org.hibernate.models.internal.jandex.JandexTypeSwitcher.switchType;
import static org.hibernate.models.internal.jandex.JandexTypeSwitchStandard.switchType;

/**
* Jandex based ClassDetailsBuilder
Expand Down Expand Up @@ -137,7 +136,7 @@ public static JandexMethodDetails buildMethodDetails(
return new JandexMethodDetails(
method,
MethodDetails.MethodKind.GETTER,
switchType( returnType, TYPE_SWITCH_STANDARD, buildingContext ),
switchType( returnType, declaringType, buildingContext ),
declaringType,
buildingContext
);
Expand All @@ -148,7 +147,7 @@ else if ( isBoolean( returnType ) && ( methodName.startsWith( "is" )
return new JandexMethodDetails(
method,
MethodDetails.MethodKind.GETTER,
switchType( returnType, TYPE_SWITCH_STANDARD, buildingContext ),
switchType( returnType, declaringType, buildingContext ),
declaringType,
buildingContext
);
Expand All @@ -162,7 +161,7 @@ else if ( isBoolean( returnType ) && ( methodName.startsWith( "is" )
return new JandexMethodDetails(
method,
MethodDetails.MethodKind.SETTER,
switchType( method.parameterType( 0 ), TYPE_SWITCH_STANDARD, buildingContext ),
switchType( method.parameterType( 0 ), declaringType, buildingContext ),
declaringType,
buildingContext
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

import static java.util.Collections.emptyList;
import static org.hibernate.models.internal.ModelsClassLogging.MODELS_CLASS_LOGGER;
import static org.hibernate.models.internal.jandex.JandexTypeSwitchStandard.TYPE_SWITCH_STANDARD;
import static org.hibernate.models.internal.jandex.JandexTypeSwitchStandard.switchType;
import static org.hibernate.models.internal.util.CollectionHelper.arrayList;
import static org.hibernate.models.internal.util.CollectionHelper.isEmpty;

Expand All @@ -41,9 +41,9 @@ public class JandexClassDetails extends AbstractAnnotationTarget implements Clas
private final ClassInfo classInfo;

private final ClassDetails superClass;
private final TypeDetails genericSuperType;
private TypeDetails genericSuperType;
private final List<TypeDetails> implementedInterfaces;
private final List<TypeVariableDetails> typeParameters;
private List<TypeVariableDetails> typeParameters;

private List<FieldDetails> fields;
private List<MethodDetails> methods;
Expand All @@ -54,9 +54,7 @@ public JandexClassDetails(ClassInfo classInfo, SourceModelBuildingContext buildi
this.classInfo = classInfo;

this.superClass = determineSuperType( classInfo, buildingContext );
this.genericSuperType = determineGenericSuperType( classInfo, buildingContext );
this.implementedInterfaces = determineInterfaces( classInfo, buildingContext );
this.typeParameters = determineTypeParameters( classInfo, buildingContext );
}

private static ClassDetails determineSuperType(
Expand All @@ -76,7 +74,7 @@ private TypeDetails determineGenericSuperType(ClassInfo classInfo, SourceModelBu
return null;
}

return JandexTypeSwitcher.switchType( classInfo.superClassType(), TYPE_SWITCH_STANDARD, buildingContext );
return switchType( classInfo.superClassType(), buildingContext );
}

private static List<TypeDetails> determineInterfaces(
Expand All @@ -89,9 +87,8 @@ private static List<TypeDetails> determineInterfaces(

final List<TypeDetails> result = arrayList( interfaceTypes.size() );
for ( Type interfaceType : interfaceTypes ) {
final TypeDetails switchedType = JandexTypeSwitcher.switchType(
final TypeDetails switchedType = switchType(
interfaceType,
TYPE_SWITCH_STANDARD,
buildingContext
);
result.add( switchedType );
Expand All @@ -107,7 +104,7 @@ private List<TypeVariableDetails> determineTypeParameters(ClassInfo classInfo, S

final ArrayList<TypeVariableDetails> result = arrayList( jandexTypeVariables.size() );
for ( TypeVariable jandexTypeVariable : jandexTypeVariables ) {
result.add( (TypeVariableDetails) JandexTypeSwitcher.switchType( jandexTypeVariable, TYPE_SWITCH_STANDARD, buildingContext ) );
result.add( (TypeVariableDetails) switchType( jandexTypeVariable, this, buildingContext ) );
}
return result;
}
Expand Down Expand Up @@ -149,6 +146,9 @@ public ClassDetails getSuperClass() {

@Override
public TypeDetails getGenericSuperType() {
if ( genericSuperType == null && classInfo.superClassType() != null ) {
genericSuperType = determineGenericSuperType( classInfo, getBuildingContext() );
}
return genericSuperType;
}

Expand All @@ -159,6 +159,9 @@ public List<TypeDetails> getImplementedInterfaces() {

@Override
public List<TypeVariableDetails> getTypeParameters() {
if ( typeParameters == null ) {
this.typeParameters = determineTypeParameters( classInfo, getBuildingContext() );
}
return typeParameters;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,17 @@
import java.util.Collection;
import java.util.Map;

import org.hibernate.models.spi.MutableMemberDetails;
import org.hibernate.models.spi.ClassDetails;
import org.hibernate.models.spi.FieldDetails;
import org.hibernate.models.spi.MutableMemberDetails;
import org.hibernate.models.spi.SourceModelBuildingContext;
import org.hibernate.models.spi.TypeDetails;

import org.jboss.jandex.AnnotationTarget;
import org.jboss.jandex.FieldInfo;
import org.jboss.jandex.Type;

import static org.hibernate.models.internal.jandex.JandexTypeSwitchStandard.TYPE_SWITCH_STANDARD;
import static org.hibernate.models.internal.jandex.JandexTypeSwitcher.switchType;
import static org.hibernate.models.internal.jandex.JandexTypeSwitchStandard.switchType;

/**
* @author Steve Ebersole
Expand All @@ -42,7 +41,7 @@ public JandexFieldDetails(
super( buildingContext );
this.fieldInfo = fieldInfo;
this.declaringType = declaringType;
this.type = switchType( fieldInfo.type(), TYPE_SWITCH_STANDARD, buildingContext );
this.type = switchType( fieldInfo.type(), declaringType, buildingContext );

this.isArray = fieldInfo.type().kind() == Type.Kind.ARRAY;
this.isPlural = isArray || type.isImplementor( Collection.class ) || type.isImplementor( Map.class );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
import org.jboss.jandex.RecordComponentInfo;
import org.jboss.jandex.Type;

import static org.hibernate.models.internal.jandex.JandexTypeSwitchStandard.TYPE_SWITCH_STANDARD;
import static org.hibernate.models.internal.jandex.JandexTypeSwitcher.switchType;
import static org.hibernate.models.internal.jandex.JandexTypeSwitchStandard.switchType;

/**
* @author Steve Ebersole
Expand All @@ -41,7 +40,7 @@ public JandexRecordComponentDetails(
super( buildingContext );
this.recordComponentInfo = recordComponentInfo;
this.declaringType = declaringType;
this.type = switchType( recordComponentInfo.type(), TYPE_SWITCH_STANDARD, buildingContext );
this.type = switchType( recordComponentInfo.type(), declaringType, buildingContext );

this.isArray = recordComponentInfo.type().kind() == Type.Kind.ARRAY;
this.isPlural = isArray || type.isImplementor( Collection.class ) || type.isImplementor( Map.class );
Expand Down
Loading