public boolean isMemberNullable(MemberShape member, CheckMode checkMode) {
        Model m = Objects.requireNonNull(model.get());
        Shape container = m.expectShape(member.getContainer());
        Shape target = m.expectShape(member.getTarget());

        switch (container.getType()) {
            case STRUCTURE:
                return checkMode.isStructureMemberOptional(container.asStructureShape().get(), member, target);
            case UNION:
            case SET:
                // Union and set members are never null.
                return false;
            case MAP:
                // Map keys are never null.
                if (member.getMemberName().equals("key")) {
                    return false;
                }
                // fall-through.
            case LIST:
                // Map values and list members are only null if they have the @sparse trait.
                return container.hasTrait(SparseTrait.ID);
            default:
                return false;
        }
    }
Checks if a member is nullable using v2 nullability rules.

<p>A {@code checkMode} parameter is required to declare what kind of
model consumer is checking if the member is optional. The authoritative
consumers like servers do not need to honor the {@link InputTrait} or
{@link ClientOptionalTrait}, while non-authoritative consumers like clients
must honor these traits.

@param member Member to check.
@param checkMode The mode used when checking if the member is considered nullable.
@return Returns true if the member is optional.
smithy-model/src/main/java/software/amazon/smithy/model/knowledge/NullableIndex.java