class DynamodbAttributeValueTransformer {

    public static AttributeValue toAttributeValueV2(final com.amazonaws.services.lambda.runtime.events.models.dynamodb.AttributeValue value) {
        if (Objects.nonNull(value.getS())) {
            return AttributeValue.builder()
                    .s(value.getS())
                    .build();

        } else if (Objects.nonNull(value.getSS())) {
            return AttributeValue.builder()
                    .ss(value.getSS())
                    .build();

        } else if (Objects.nonNull(value.getN())) {
            return AttributeValue.builder()
                    .n(value.getN())
                    .build();

        } else if (Objects.nonNull(value.getNS())) {
            return AttributeValue.builder()
                    .ns(value.getNS())
                    .build();

        } else if (Objects.nonNull(value.getB())) {
            return AttributeValue.builder()
                    .b(SdkBytes.fromByteBuffer(value.getB()))
                    .build();

        } else if (Objects.nonNull(value.getBS())) {
            return AttributeValue.builder()
                    .bs(value.getBS().stream()
                            .map(SdkBytes::fromByteBuffer)
                            .collect(Collectors.toList()))
                    .build();

        } else if (Objects.nonNull(value.getBOOL())) {
            return AttributeValue.builder()
                    .bool(value.getBOOL())
                    .build();

        } else if (Objects.nonNull(value.getL())) {
            return AttributeValue.builder()
                    .l(value.getL().stream()
                            .map(DynamodbAttributeValueTransformer::toAttributeValueV2)
                            .collect(Collectors.toList()))
                    .build();

        } else if (Objects.nonNull(value.getM())) {
            return AttributeValue.builder()
                    .m(toAttributeValueMapV2(value.getM()))
                    .build();

        } else if (Objects.nonNull(value.getNULL())) {
            return AttributeValue.builder()
                    .nul(value.getNULL())
                    .build();

        } else {
            throw new IllegalArgumentException(
                    String.format("Unsupported attributeValue type: %s", value));
        }
    }

}

class DynamodbAttributeValueTransformerTest {

    private static final String valueN;
    private static final List<String> valueNS;
    private static final String valueS;
    private static final List<String> valueSS;
    private static final ByteBuffer valueB;
    private static final List<ByteBuffer> valueBS;
    private static final boolean valueBOOL;
    private static final boolean valueNUL;
    private static final String keyM1;
    private static final String keyM2;
    public static final AttributeValue attributeValueN_event;
    public static final AttributeValue attributeValueNS_event;
    public static final AttributeValue attributeValueS_event;
    public static final AttributeValue attributeValueSS_event;
    public static final AttributeValue attributeValueB_event;
    public static final AttributeValue attributeValueBS_event;
    public static final AttributeValue attributeValueBOOL_event;
    public static final AttributeValue attributeValueNUL_event;
    public static final AttributeValue attributeValueM_event;
    public static final AttributeValue attributeValueL_event;
    public static final software.amazon.awssdk.services.dynamodb.model.AttributeValue attributeValueN_v2;
    public static final software.amazon.awssdk.services.dynamodb.model.AttributeValue attributeValueNS_v2;
    public static final software.amazon.awssdk.services.dynamodb.model.AttributeValue attributeValueS_v2;
    public static final software.amazon.awssdk.services.dynamodb.model.AttributeValue attributeValueSS_v2;
    public static final software.amazon.awssdk.services.dynamodb.model.AttributeValue attributeValueB_v2;
    public static final software.amazon.awssdk.services.dynamodb.model.AttributeValue attributeValueBS_v2;
    public static final software.amazon.awssdk.services.dynamodb.model.AttributeValue attributeValueBOOL_v2;
    public static final software.amazon.awssdk.services.dynamodb.model.AttributeValue attributeValueNUL_v2;
    public static final software.amazon.awssdk.services.dynamodb.model.AttributeValue attributeValueM_v2;
    public static final software.amazon.awssdk.services.dynamodb.model.AttributeValue attributeValueL_v2;

    @Test
    public void testToAttributeValueV2_IllegalArgumentWhenNull_BOOL() {

        Assertions.assertThrows(IllegalArgumentException.class, () ->
                DynamodbAttributeValueTransformer.toAttributeValueV2(new AttributeValue().withBOOL(null))
        );
    }

}