Java Code Examples for software.amazon.awssdk.services.dynamodb.model.AttributeValue#m()
The following examples show how to use
software.amazon.awssdk.services.dynamodb.model.AttributeValue#m() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DynamoDBPositionsStorage.java From liiklus with MIT License | 6 votes |
static Map<Integer, Long> toPositions(Map<String, AttributeValue> item) { if (item == null) { return null; } AttributeValue positions = item.get("positions"); if (positions == null || positions.m() == null) { return null; } return positions.m().entrySet().stream() .collect(Collectors.toMap( it -> Integer.parseInt(it.getKey()), it -> Long.parseLong(it.getValue().n()) )); }
Example 2
Source File: EnhancedAttributeValue.java From aws-sdk-java-v2 with Apache License 2.0 | 5 votes |
/** * Convert this {@link EnhancedAttributeValue} into a generated {@code Map<String, AttributeValue>}. * * <p> * This call will fail with a {@link RuntimeException} if {@link #isMap()} is false. */ public Map<String, AttributeValue> toAttributeValueMap() { Validate.validState(isMap(), "Cannot convert an attribute value of type %s to a generated item. Must be %s.", type(), AttributeValueType.M); AttributeValue generatedAttributeValue = toAttributeValue(); Validate.validState(generatedAttributeValue.m() != null && !(generatedAttributeValue.m() instanceof SdkAutoConstructMap), "Map EnhancedAttributeValue was not converted into a Map AttributeValue."); return generatedAttributeValue.m(); }
Example 3
Source File: AttributeValueCoder.java From beam with Apache License 2.0 | 5 votes |
@Override public void encode(AttributeValue value, OutputStream outStream) throws IOException { if (value.s() != null) { StringUtf8Coder.of().encode(AttributeValueType.s.toString(), outStream); StringUtf8Coder.of().encode(value.s(), outStream); } else if (value.n() != null) { StringUtf8Coder.of().encode(AttributeValueType.n.toString(), outStream); StringUtf8Coder.of().encode(value.n(), outStream); } else if (value.bool() != null) { StringUtf8Coder.of().encode(AttributeValueType.bool.toString(), outStream); BooleanCoder.of().encode(value.bool(), outStream); } else if (value.b() != null) { StringUtf8Coder.of().encode(AttributeValueType.b.toString(), outStream); ByteArrayCoder.of().encode(value.b().asByteArray(), outStream); } else if (value.ss() != null && value.ss().size() > 0) { StringUtf8Coder.of().encode(AttributeValueType.ss.toString(), outStream); LIST_STRING_CODER.encode(value.ss(), outStream); } else if (value.ns() != null && value.ns().size() > 0) { StringUtf8Coder.of().encode(AttributeValueType.ns.toString(), outStream); LIST_STRING_CODER.encode(value.ns(), outStream); } else if (value.bs() != null && value.bs().size() > 0) { StringUtf8Coder.of().encode(AttributeValueType.bs.toString(), outStream); LIST_BYTE_CODER.encode(convertToListByteArray(value.bs()), outStream); } else if (value.l() != null && value.l().size() > 0) { StringUtf8Coder.of().encode(AttributeValueType.l.toString(), outStream); LIST_ATTRIBUTE_CODER.encode(value.l(), outStream); } else if (value.m() != null && value.m().size() > 0) { StringUtf8Coder.of().encode(AttributeValueType.m.toString(), outStream); MAP_ATTRIBUTE_CODER.encode(value.m(), outStream); } else if (value.nul() != null) { StringUtf8Coder.of().encode(AttributeValueType.nul.toString(), outStream); BooleanCoder.of().encode(value.nul(), outStream); } else { throw new CoderException("Unknown Type"); } }
Example 4
Source File: AttributeValueMarshallerTest.java From aws-dynamodb-encryption-java with Apache License 2.0 | 5 votes |
private void assertAttributesAreEqual(AttributeValue o1, AttributeValue o2) { assertEquals(o1.b(), o2.b()); assertSetsEqual(o1.bs(), o2.bs()); assertEquals(o1.n(), o2.n()); assertSetsEqual(o1.ns(), o2.ns()); assertEquals(o1.s(), o2.s()); assertSetsEqual(o1.ss(), o2.ss()); assertEquals(o1.bool(), o2.bool()); assertEquals(o1.nul(), o2.nul()); if (o1.l() != null) { assertNotNull(o2.l()); final List<AttributeValue> l1 = o1.l(); final List<AttributeValue> l2 = o2.l(); assertEquals(l1.size(), l2.size()); for (int x = 0; x < l1.size(); ++x) { assertAttributesAreEqual(l1.get(x), l2.get(x)); } } if (o1.m() != null) { assertNotNull(o2.m()); final Map<String, AttributeValue> m1 = o1.m(); final Map<String, AttributeValue> m2 = o2.m(); assertEquals(m1.size(), m2.size()); for (Map.Entry<String, AttributeValue> entry : m1.entrySet()) { assertAttributesAreEqual(entry.getValue(), m2.get(entry.getKey())); } } }
Example 5
Source File: AttrMatcher.java From aws-dynamodb-encryption-java with Apache License 2.0 | 5 votes |
public static boolean attrEquals(AttributeValue e, AttributeValue a) { if (!isEqual(e.b(), a.b()) || !isEqual(e.bool(), a.bool()) || !isSetEqual(e.bs(), a.bs()) || !isEqual(e.n(), a.n()) || !isSetEqual(e.ns(), a.ns()) || !isEqual(e.nul(), a.nul()) || !isEqual(e.s(), a.s()) || !isSetEqual(e.ss(), a.ss())) { return false; } // Recursive types need special handling if (e.m() == null ^ a.m() == null) { return false; } else if (e.m() != null) { if (!e.m().keySet().equals(a.m().keySet())) { return false; } for (final String key : e.m().keySet()) { if (!attrEquals(e.m().get(key), a.m().get(key))) { return false; } } } if (e.l() == null ^ a.l() == null) { return false; } else if (e.l() != null) { if (e.l().size() != a.l().size()) { return false; } for (int x = 0; x < e.l().size(); x++) { if (!attrEquals(e.l().get(x), a.l().get(x))) { return false; } } } return true; }