@@ -1264,26 +1264,25 @@ private boolean shouldForceNotNull(Nullability nullability, boolean optional) {
12641264 * Should this property be considered optional, without considering
12651265 * whether it is primitive?
12661266 *
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
12681269 */
12691270 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 ();
12771275 }
12781276
12791277 /**
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?
12821280 */
12831281 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 ;
12871286 }
12881287 else if ( attributeMember .isArray () ) {
12891288 return true ;
0 commit comments