public static Object fromDynamoDbAttributeValue()

in dynamodb-api/src/main/java/com/awssamples/iot/dynamodb/api/SharedHelper.java [93:134]


    public static Object fromDynamoDbAttributeValue(AttributeValue attributeValue) {
        if (attributeValue.s() != null) {
            return attributeValue.s();
        }

        if (attributeValue.n() != null) {
            return attributeValue.n();
        }

        if (attributeValue.b() != null) {
            return attributeValue.b();
        }

        if (!attributeValue.bs().isEmpty()) {
            return attributeValue.bs();
        }

        if (!attributeValue.ss().isEmpty()) {
            return attributeValue.ss();
        }

        if (!attributeValue.ns().isEmpty()) {
            return attributeValue.ns();
        }

        if (attributeValue.bool() != null) {
            return attributeValue.bool();
        }

        if (!attributeValue.l().isEmpty()) {
            return attributeValue.l();
        }

        if (attributeValue.m() != null) {
            return attributeValue.m().entrySet()
                    .stream()
                    .map(e -> new AbstractMap.SimpleImmutableEntry<>(e.getKey(), fromDynamoDbAttributeValue(e.getValue())))
                    .collect(toMap());
        }

        throw new IllegalArgumentException("Unsupported attribute value: " + attributeValue);
    }