Skip to content

Commit 1ba5288

Browse files
committed
#9 - Add details about "index" and "element"/"component" types to MemberDetails
#21 - Work on generics / parameterized-types
1 parent 767272e commit 1ba5288

File tree

2 files changed

+31
-16
lines changed

2 files changed

+31
-16
lines changed

src/main/java/org/hibernate/models/internal/jandex/JandexMethodDetails.java

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,20 @@ public JandexMethodDetails(
5858
argumentTypes.add( classDetailsRegistry.resolveClassDetails( methodInfo.parameterType( i ).name().toString() ) );
5959
}
6060

61-
if ( type != null ) {
62-
this.isArray = methodInfo.returnType().kind() == Type.Kind.ARRAY;
63-
this.isPlural = isArray || type.isImplementor( Collection.class ) || type.isImplementor( Map.class );
64-
}
65-
else {
66-
this.isArray = false;
67-
this.isPlural = false;
61+
switch ( methodKind ) {
62+
case GETTER -> {
63+
this.isArray = methodInfo.returnType().kind() == Type.Kind.ARRAY;
64+
this.isPlural = isArray || type.isImplementor( Collection.class ) || type.isImplementor( Map.class );
65+
}
66+
case SETTER -> {
67+
assert methodInfo.parametersCount() == 1;
68+
this.isArray = methodInfo.parameterType( 0 ).kind() == Type.Kind.ARRAY;
69+
this.isPlural = isArray || type.isImplementor( Collection.class ) || type.isImplementor( Map.class );
70+
}
71+
default -> {
72+
this.isArray = false;
73+
this.isPlural = false;
74+
}
6875
}
6976
}
7077

src/main/java/org/hibernate/models/internal/jdk/JdkMethodDetails.java

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
import org.hibernate.models.spi.MethodDetails;
2020
import org.hibernate.models.spi.SourceModelBuildingContext;
2121

22+
import org.jboss.jandex.Type;
23+
2224
/**
2325
* @author Steve Ebersole
2426
*/
@@ -55,15 +57,21 @@ public JdkMethodDetails(
5557
argumentTypes.add( classDetailsRegistry.resolveClassDetails( method.getParameterTypes()[i].getName() ) );
5658
}
5759

58-
if ( type != null ) {
59-
this.isArray = method.getReturnType().isArray();
60-
this.isPlural = isArray
61-
|| Collection.class.isAssignableFrom( method.getReturnType() )
62-
|| Map.class.isAssignableFrom( method.getReturnType() );
63-
}
64-
else {
65-
this.isArray = false;
66-
this.isPlural = false;
60+
61+
switch ( methodKind ) {
62+
case GETTER -> {
63+
this.isArray = method.getReturnType().isArray();
64+
this.isPlural = isArray || type.isImplementor( Collection.class ) || type.isImplementor( Map.class );
65+
}
66+
case SETTER -> {
67+
assert method.getParameterCount() == 1;
68+
this.isArray = method.getParameterTypes()[0].isArray();
69+
this.isPlural = isArray || type.isImplementor( Collection.class ) || type.isImplementor( Map.class );
70+
}
71+
default -> {
72+
this.isArray = false;
73+
this.isPlural = false;
74+
}
6775
}
6876
}
6977

0 commit comments

Comments
 (0)