if ( getterResult == null && reflector.isAssignableKey(method) ) {
onAutoGenerateAssignableKey(method, attributeName);
}
else {
AttributeValue newAttributeValue = converter.convert(method, getterResult);
if ( newAttributeValue == null ) {
throw new DynamoDBMappingException(
"Null or empty value for key: " + method);
}
if ( newAttributeValue.getS() == null
&& newAttributeValue.getN() == null
&& newAttributeValue.getB() == null) {
throw new DynamoDBMappingException(
"Keys must be scalar values (String, Number, "
+ "or Binary). Got " + newAttributeValue
+ " for key " + method);
}
onKeyAttributeValue(attributeName, newAttributeValue);
}
}
/*
* Next construct an update for every non-key property
*/
for ( Method method : reflector.getRelevantGetters(clazz) ) {
// Skip any key methods, since they are handled separately
if ( keyGetters.contains(method) )
continue;
Object getterResult = ReflectionUtils.safeInvoke(method, object);
String attributeName = reflector.getAttributeName(method);
/*
* If this is a versioned field, update it
*/
if ( reflector.isVersionAttributeGetter(method) ) {
onVersionAttribute(method, getterResult, attributeName);
}
/*
* Otherwise apply the update value for this attribute.
*/
else {
AttributeValue currentValue = converter.convert(method, getterResult);
if ( currentValue != null ) {
onNonKeyAttribute(attributeName, currentValue);
} else {
onNullNonKeyAttribute(attributeName);
}