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(
58
58
argumentTypes .add ( classDetailsRegistry .resolveClassDetails ( methodInfo .parameterType ( i ).name ().toString () ) );
59
59
}
60
60
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
+ }
68
75
}
69
76
}
70
77
Original file line number Diff line number Diff line change 19
19
import org .hibernate .models .spi .MethodDetails ;
20
20
import org .hibernate .models .spi .SourceModelBuildingContext ;
21
21
22
+ import org .jboss .jandex .Type ;
23
+
22
24
/**
23
25
* @author Steve Ebersole
24
26
*/
@@ -55,15 +57,21 @@ public JdkMethodDetails(
55
57
argumentTypes .add ( classDetailsRegistry .resolveClassDetails ( method .getParameterTypes ()[i ].getName () ) );
56
58
}
57
59
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
+ }
67
75
}
68
76
}
69
77
You can’t perform that action at this time.
0 commit comments