File tree Expand file tree Collapse file tree 2 files changed +31
-16
lines changed
src/main/java/org/hibernate/models/internal Expand file tree Collapse file tree 2 files changed +31
-16
lines changed Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change 1919import org .hibernate .models .spi .MethodDetails ;
2020import 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
You can’t perform that action at this time.
0 commit comments