DATACOUCH-58 allow for null values to be persisted for List elements and Map values.

This commit is contained in:
Ken Dombeck
2013-12-13 11:33:58 -06:00
committed by Michael Nitschinger
parent b11fc6c53c
commit 15ad87a82f
4 changed files with 15 additions and 21 deletions

View File

@@ -227,6 +227,8 @@ public class JacksonTranslationService implements TranslationService, Initializi
}
case VALUE_NUMBER_FLOAT:
return parser.getValueAsDouble();
case VALUE_NULL:
return null;
default:
throw new MappingException("Could not decode primitve value " + token);
}

View File

@@ -259,13 +259,11 @@ public class CouchbaseDocument implements CouchbaseStorable {
* <p>If this is not the case, a {@link IllegalArgumentException} is
* thrown.</p>
*
* Objects that are NULL cannot be stored.
*
* @param value the object to verify its type.
*/
private void verifyValueType(final Object value) {
if(value == null) {
throw new IllegalArgumentException("Attribute of type null cannot be stored.");
return;
}
final Class<?> clazz = value.getClass();
if (simpleTypeHolder.isSimpleType(clazz)) {

View File

@@ -69,7 +69,7 @@ public class CouchbaseList implements CouchbaseStorable {
* @return the {@link CouchbaseList} object for chaining purposes.
*/
public final CouchbaseList put(final Object value) {
verifyValueType(value.getClass());
verifyValueType(value);
payload.add(value);
return this;
@@ -170,9 +170,14 @@ public class CouchbaseList implements CouchbaseStorable {
* <p>If this is not the case, a {@link IllegalArgumentException} is
* thrown.</p>
*
* @param clazz the class type to check and verify.
* @param value the object to verify its type.
*/
private void verifyValueType(final Class<?> clazz) {
private void verifyValueType(final Object value) {
if(value == null) {
return;
}
final Class<?> clazz = value.getClass();
if (simpleTypeHolder.isSimpleType(clazz)) {
return;
}