@@ -1264,26 +1264,25 @@ private boolean shouldForceNotNull(Nullability nullability, boolean optional) {
1264
1264
* Should this property be considered optional, without considering
1265
1265
* whether it is primitive?
1266
1266
*
1267
- * @apiNote Poorly named to a degree. The intention is really whether non-optional is explicit
1267
+ * @apiNote Poorly named to a degree.
1268
+ * The intention is really whether non-optional is explicit
1268
1269
*/
1269
1270
private static boolean isExplicitlyOptional (MemberDetails attributeMember ) {
1270
- final Basic basicAnn = attributeMember .getDirectAnnotationUsage ( Basic .class );
1271
- if ( basicAnn == null ) {
1272
- // things are optional (nullable) by default. If there is no annotation, that cannot be altered
1273
- return true ;
1274
- }
1275
-
1276
- return basicAnn .optional ();
1271
+ final Basic basic = attributeMember .getDirectAnnotationUsage ( Basic .class );
1272
+ // things are optional (nullable) by default.
1273
+ // If there is no annotation, that cannot be altered
1274
+ return basic == null || basic .optional ();
1277
1275
}
1278
1276
1279
1277
/**
1280
- * Should this property be considered optional, taking into
1281
- * account whether it is primitive?
1278
+ * Should this property be considered optional, taking into account
1279
+ * whether it is primitive?
1282
1280
*/
1283
1281
public static boolean isOptional (MemberDetails attributeMember , PropertyHolder propertyHolder ) {
1284
- final Basic basicAnn = attributeMember .getDirectAnnotationUsage ( Basic .class );
1285
- if ( basicAnn != null ) {
1286
- return basicAnn .optional ();
1282
+ final Basic basic = attributeMember .getDirectAnnotationUsage ( Basic .class );
1283
+ if ( basic != null ) {
1284
+ return basic .optional ()
1285
+ && attributeMember .getType ().getTypeKind () != TypeDetails .Kind .PRIMITIVE ;
1287
1286
}
1288
1287
else if ( attributeMember .isArray () ) {
1289
1288
return true ;
0 commit comments